home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 151-175 / scopedisk168 / asmmacros / asmmacros_02.doc < prev    next >
Text File  |  1995-03-19  |  87KB  |  2,833 lines

  1. *****************************************************************************
  2. *
  3. *    AsmMacros
  4. *
  5. *    Rev. 01   14 Mar 88  - Initial release.
  6. *    Rev. 02    9 Feb 89  - Added support for CAPE-68K assembler and
  7. *                            support of reentrant (pure) programming.
  8. *
  9. *
  10. *____________________________________________________________________________
  11. *
  12. *    When writing a program using these macros, the following rules apply:
  13. *
  14. *         - Must include the file called CoreMacros.i . This file contains
  15. *            the following macros:
  16. *
  17. *                 DefineSections           CallLib
  18. *                 OpenLib                  CloseLib
  19. *                 DefDS                    DS_BSS
  20. *                 OnReEntrant              OffReEntrant
  21. *
  22. *         - Other macros must be included individually if they are used.
  23. *
  24. *         - Must do the DefineSections macro at the start of the program.
  25. *            The other macros depend on this.
  26. *
  27. *         - These macros must only be invoked from the CODE section.
  28. *
  29. *
  30. *____________________________________________________________________________
  31. *
  32. *
  33. *    With the release of AmigaDOS 1.3, commands can be made resident using
  34. *    the RESIDENT command. Resident programs must be both reentrant and
  35. *    re-executable. A program which meets both these requirements is con-
  36. *    sidered pure.
  37. *
  38. *    These macros support the creation of reentrant programming by using
  39. *    the A5 register to point to a block of memory in which uninitialized
  40. *    data is stored. This block of memory is used in place of the BSS
  41. *    section.
  42. *
  43. *    Reentrant programs must begin by invoking the AllocUDS macro. They
  44. *    must end by invoking the FreeUDS macro. Refer to the file called
  45. *    PureTemplate for an example of how this is done.
  46. *
  47. *
  48. *
  49. *
  50. *****************************************************************************
  51.  
  52. *****************************************************************************
  53. *
  54. *    DefineSections           MACRO                           25 Dec 88
  55. *
  56. *    NAME:
  57. *         DefineSections  - Defines the DATA, BSS and CODE program sections.
  58. *
  59. *    SYNOPSIS:
  60. *         DefineSections [<ProgramName>]
  61. *
  62. *    FUNCTION:
  63. *         This macro defines the DATA, BSS and CODE program sections. This
  64. *          is required for the other macros to work correctly.
  65. *
  66. *         If <ProgramName> is specified, the program unit will be given
  67. *          this name.
  68. *
  69.  
  70.  
  71. DefineSections MACRO
  72. *-------------------------------;    Start of DefineSections macro.
  73.                NOLIST
  74.                IFEQ NARG-1
  75.                LIST
  76.                IDNT "\1"
  77.                NOLIST
  78.                ENDC
  79.                IFND ReEntrant
  80. ReEntrant      SET 0
  81.                ENDC
  82.                IFND CAPE
  83.                LIST
  84. MetacomcoFix:  SECTION   "",CODE             ; This un-named code section
  85.                JMP CodeStart                 ;  is needed to fix a bug in
  86.                                              ;  the MetaComCo assembler.
  87.                NOLIST
  88.                ENDC
  89.                LIST
  90. DefDSPointer   SET 0
  91. CurrentLibID   SET 0
  92.                SECTION   CodeSection,CODE    ; Relocatable code section
  93. CodeStart:
  94.                SECTION   DataSection,DATA    ; Initialized data section
  95. DataStart:
  96.                SECTION   BSS_Section,BSS     ; Un-initialized data section
  97. BSS_Start:
  98.                SECTION   CodeSection,CODE    ; Relocatable code section
  99. *-------------------------------;    End of DefineSections macro.
  100.                ENDM
  101.  
  102. *****************************************************************************
  103. *
  104. *    DefDS                    MACRO                           26 Dec 88
  105. *
  106. *    NAME:
  107. *         DefDS - Define an offset to a location in the RAM block used for
  108. *                  un-initialized data storage.
  109. *
  110. *    SYNOPSIS:
  111. *         DefDS <label>,<size>
  112. *
  113. *    FUNCTION:
  114. *         This macro defines an offset to a location in the RAM block used
  115. *          for un-initialized data storage. The <label> is equated to this
  116. *          offset value. The data storage size will be <size> long words.
  117. *          This macro is used when the reentrant macro expansion feature is
  118. *          turned on.
  119. *
  120. *         See also AllocUDS.
  121. *
  122.  
  123. DefDS          MACRO
  124.                NOLIST
  125.                IFND \1
  126. \1             EQU DefDSPointer
  127. DefDSPointer   SET DefDSPointer+(4*\2)
  128.                ENDC
  129.                LIST
  130.                ENDM
  131.  
  132. *****************************************************************************
  133.  
  134. *****************************************************************************
  135. *
  136. *    DS_BSS                   MACRO                           13 Sept 88
  137. *
  138. *    NAME:
  139. *         DS_BSS - Define data storage in a BSS section.
  140. *
  141. *    SYNOPSIS:
  142. *         DS_BSS <label>,<size>,.B|.W|.L
  143. *
  144. *    FUNCTION:
  145. *         This macro defines data storage in a BSS section. The <label> is
  146. *          equated to this value. The third argument tells whether the units
  147. *          of <size> are byte, word, or long.
  148. *
  149.  
  150. DS_BSS    MACRO
  151.           NOLIST
  152.           IFND \1
  153.           SECTION BSS_Section,BSS
  154.           IFC "\3",".W"
  155.           CNOP 0,2
  156.           ENDC
  157.           IFC "\3",".L"
  158.           CNOP 0,4
  159.           ENDC
  160. \1:
  161.           DS\3 \2
  162.           SECTION CodeSection,CODE
  163.           ENDC
  164.           LIST
  165.           ENDM
  166.  
  167. *****************************************************************************
  168. *
  169. *    OnReEntrant, OffReEntrant          MACRO                 13 Sept 88
  170. *
  171. *    FUNCTION:
  172. *         These macros turn the reentrant macro expansion feature on or off.
  173. *
  174. *         When the reentrant macro expansion feature is turned on, all
  175. *          BSS-type data space is in a block of RAM pointed to by A5.
  176. *
  177. *         See also AllocUDS.
  178. *
  179.  
  180. OnReEntrant    MACRO
  181.                NOLIST
  182. ReEntrant      SET 1
  183.                LIST
  184.                ENDM
  185.  
  186. OffReEntrant   MACRO
  187.                NOLIST
  188. ReEntrant      SET 0
  189.                LIST
  190.                ENDM
  191.  
  192. *****************************************************************************
  193.  
  194. *****************************************************************************
  195. *
  196. *    CallLib                  MACRO                            9 Feb 89
  197. *
  198. *    NAME:
  199. *         CallLib  - Call a subroutine of a library.
  200. *
  201. *    SYNOPSIS:
  202. *         CallLib <SubroutineName>,<libname>
  203. *
  204. *    FUNCTION:
  205. *         This macro calls a subroutine of a library. The library must
  206. *          have been previously opened, and the library pointer must be
  207. *          at <libname>.library.ptr .
  208. *
  209. *         See also OpenLib.
  210. *
  211.  
  212. CallLib   MACRO
  213.      NOLIST
  214.      IFND _LVO\1.Ref
  215. _LVO\1.Ref SET 1
  216.      LIST
  217.         XREF _LVO\1
  218.      NOLIST
  219.      ENDC
  220.      IFEQ ReEntrant-1
  221.      LIST
  222.         MOVE.L \2.library.ptr(A5),A6
  223.      NOLIST
  224.      ENDC
  225.      IFNE ReEntrant-1
  226.      LIST
  227.         MOVE.L \2.library.ptr,A6
  228.      NOLIST
  229.      ENDC
  230.      LIST
  231.         JSR _LVO\1(A6)
  232.      ENDM
  233.  
  234. *****************************************************************************
  235.  
  236. *****************************************************************************
  237. *
  238. *    OpenLib                  MACRO                          25 Dec 88
  239. *
  240. *    NAME:
  241. *         OpenLib  - Open a library.
  242. *
  243. *    SYNOPSIS:
  244. *         OpenLib <libname>
  245. *
  246. *                  Returns:  pointer to the library at <libname>.ptr
  247. *
  248. *                            Z-flag = 1 if fail
  249. *
  250. *    FUNCTION:
  251. *         This macro returns a pointer to a library that was previously
  252. *          installed into the system. If it is not successful, it will return
  253. *          a library pointer of zero and set the zero flag.
  254. *
  255. *         See also CloseLib.
  256. *
  257. *    INPUTS:
  258. *         <libname>   - Typed in as the first argument of the macro.
  259. *
  260. *    RESULTS:
  261. *         pointer to library - Returned in memory at the address labeled
  262. *                               "<libname>.ptr".
  263. *
  264. *         fail               - Zero flag = true if failed, false if o.k.
  265. *
  266.  
  267. OpenLib   MACRO
  268. *------------------------------; Start of OpenLib macro.
  269.      NOLIST
  270.                                ; Define _AbsExecBase and _LVOOpenLibrary if
  271.      IFND _AbsExecBase         ;  they have not yet been defined.
  272.      LIST
  273.      XREF _AbsExecBase
  274.      NOLIST
  275.      ENDC
  276.      IFND _LVOOpenLibrary
  277.      LIST
  278.      XREF _LVOOpenLibrary
  279.      NOLIST
  280.      ENDC
  281.      LIST
  282.      MOVE.L _AbsExecBase,A6    ; Do set-up for _LVOOpenLibrary.
  283.      CLR.L D0
  284.      MOVE.L #\1.str,A1
  285.      SECTION DataSection,DATA  ; This is the <libname> ASCII string.
  286. \1.str:
  287.      DC.B '\1',0
  288.      CNOP 0,2
  289.      SECTION CodeSection,CODE
  290.      JSR _LVOOpenLibrary(A6)   ; Call OpenLibrary to open <libname>.
  291.      NOLIST
  292.      IFEQ ReEntrant-1
  293.      LIST
  294.      DefDS \1.ptr,1
  295.      MOVE.L D0,\1.ptr(A5)
  296.      NOLIST
  297.      ENDC
  298.      IFNE ReEntrant-1
  299.      LIST
  300.      MOVE.L D0,\1.ptr
  301.      DS_BSS \1.ptr,1,.L
  302.      NOLIST
  303.      ENDC
  304.      LIST
  305.      TST.L D0                  ; Make the zero flag indicate failure.
  306. *------------------------------; End of OpenLib macro.
  307.      ENDM
  308.  
  309. *****************************************************************************
  310.  
  311. *****************************************************************************
  312. *
  313. *    CloseLib               exec.library  MACRO        Rev: 13 Sept 88
  314. *
  315. *    NAME:
  316. *         CloseLib  - Close a library.
  317. *
  318. *    SYNOPSIS:
  319. *         CloseLib <libname>
  320. *
  321. *                  Returns:  Nothing.
  322. *
  323. *    FUNCTION:
  324. *         This macro tells the library manager that there is one fewer task
  325. *          currently using the specified library. This allows the operating
  326. *          system to purge the library from RAM if the extra RAM space is
  327. *          needed and no task is using it. Since this macro invokes the exec
  328. *          library (exec.library), the exec library should be closed last.
  329. *
  330. *         See also OpenLib.
  331. *
  332. *    INPUTS:
  333. *         <libname>       - Typed in as the first argument of the macro.
  334. *                            "<libname>.ptr" must have been created by the
  335. *                            OpenLib macro.
  336. *
  337. *         exec.library.ptr - Since this macro invokes the exec library, the
  338. *                            exec library must have been opened previously
  339. *                            by invoking the "OpenLib exec.library"
  340. *                            macro command.
  341. *
  342.  
  343.  
  344. CloseLib       MACRO
  345. *------------------------------; Start of CloseLib macro.
  346.                                ; Put the library pointer in A1.
  347.      NOLIST
  348.      IFEQ ReEntrant-1
  349.      LIST
  350.      MOVE.L \1.ptr(A5),A1
  351.      NOLIST
  352.      ENDC
  353.      IFNE ReEntrant-1
  354.      LIST
  355.      MOVE.L \1.ptr,A1
  356.      NOLIST
  357.      ENDC
  358.      LIST
  359.      CallLib CloseLibrary,exec ; Call CloseLibrary.
  360. *------------------------------; End of CloseLib macro.
  361.      ENDM
  362.  
  363. *****************************************************************************
  364.  
  365. *****************************************************************************
  366. *
  367. *    AllocMem            exec.library  MACRO                13 Sept 88
  368. *
  369. *    NAME:
  370. *         AllocMem - Allocate memory given certain requirements
  371. *
  372. *    SYNOPSIS:
  373. *      AllocMem <MemBlockName>,D,<BlockSize> [,PUBLIC!CHIP!CLEAR]
  374. *      AllocMem <MemBlockName>,I,<PointerToBlockSize> [,PUBLIC!CHIP!CLEAR]
  375. *      AllocMem <MemBlockName>,R,D0 [,PUBLIC!CHIP!CLEAR]
  376. *
  377. *                  Returns:  Start address of the memory block in D0 and
  378. *                             at "<MemBlockName>.Adr"
  379. *                            Block size saved at "<MemBlockName>.Size"
  380. *                            Z-flag = 1 if fail.
  381. *
  382. *    FUNCTION:
  383. *         This macro is used to get allocation of a block of memory. The
  384. *          first argument is the name you want the block to be called. This
  385. *          macro will create "<MemBlockName>.Adr", and "<MemBlockName>.Size"
  386. *          unless they already exist.
  387. *
  388. *         For the third argument, either specify the number of bytes the
  389. *          block should contain (direct mode), point to the memory location
  390. *          where the block size is specified (indirect mode), or specify "D0"
  391. *          to have D0 specify the number of bytes (register mode).
  392. *
  393. *         Specify PUBLIC if the memory is to be accessible by other tasks;
  394. *          otherwise, it will be private. Specify CHIP if the memory should
  395. *          be accessible by the custom chips; otherwise, it will try to use
  396. *          fast memory, if available. Specify CLEAR if you want the memory
  397. *          initialized to all zeros. If it is not successful, it will set
  398. *          the zero flag.
  399. *
  400. *         See also FreeMem.
  401. *
  402. *    INPUTS:
  403. *         "D","I" or "R"      - Indicates "direct", "indirect" or "register"
  404. *                                mode for the third argument.
  405. *
  406. *         <MemBlockName>       - The name you want the block to be called.
  407. *
  408. *         <PointerToBlockSize> - Specifies number of bytes in the block.
  409. *         <BlockSize> or "D0"
  410. *
  411. *         [PUBLIC!CHIP!CLEAR]  - Type PUBLIC, CHIP, and/or CLEAR, separated
  412. *                                 by a "!".
  413. *
  414. *         exec.library.LP      - Must have been defined by invoking the
  415. *                                 "OpenLib exec.library" macro command.
  416. *
  417.  
  418.  
  419. AllocMem    MACRO
  420. *------------------------------; Start of AllocMem macro.
  421.      NOLIST
  422.      IFC "\2","D"              ; If \3 uses direct mode, then.
  423.      LIST
  424.                                ; Put the block size in D0.
  425.      MOVE.L #\3,D0
  426.      NOLIST
  427.      ENDC
  428.      IFC "\2","I"              ; If \3 uses indirect mode, then.
  429.      LIST
  430.                                ; Put the block size in D0.
  431.      NOLIST
  432.      IFEQ ReEntrant-1
  433.      LIST
  434.      MOVE.L \3(A5),D0
  435.      NOLIST
  436.      ENDC
  437.      IFNE ReEntrant-1
  438.      LIST
  439.      MOVE.L \3,D0
  440.      NOLIST
  441.      ENDC
  442.      ENDC
  443.      LIST
  444.                                ; Save the block size at <MemBlockName>.Size
  445.      NOLIST
  446.      IFEQ ReEntrant-1
  447.      LIST
  448.      DefDS \1.Size,1
  449.      MOVE.L D0,\1.Size(A5)
  450.      NOLIST
  451.      ENDC
  452.      IFNE ReEntrant-1
  453.      LIST
  454.      MOVE.L D0,\1.Size
  455.      DS_BSS \1.Size,1,.L
  456.      NOLIST
  457.      ENDC
  458.      IFNE NARG-4               ; If \4 is not given, then
  459.      LIST
  460.      CLR.L D1                  ; Accept any memory.
  461.      NOLIST
  462.      ENDC
  463.      IFEQ NARG-4               ; If \4 is given, then
  464. PUBLIC SET 1
  465. CHIP   SET 2
  466. CLEAR  SET $10000
  467.      LIST
  468.                                ; Set the appropriate bits in D1.
  469.      MOVE.L #\4,D1
  470.      NOLIST
  471.      ENDC
  472.      LIST
  473.      CallLib AllocMem,exec     ; Call AllocMem.
  474.                                ; Save the address of the memory block at
  475.                                ;  <MemBlockName>.Adr
  476.      NOLIST
  477.      IFEQ ReEntrant-1
  478.      LIST
  479.      DefDS \1.Adr,1
  480.      MOVE.L D0,\1.Adr(A5)
  481.      NOLIST
  482.      ENDC
  483.      IFNE ReEntrant-1
  484.      LIST
  485.      MOVE.L D0,\1.Adr
  486.      DS_BSS \1.Adr,1,.L
  487.      NOLIST
  488.      ENDC
  489.      LIST
  490.      TST.L D0                  ; Make the zero flag indicate failure.
  491. *------------------------------; End of AllocMem macro.
  492.      ENDM
  493.  
  494. *****************************************************************************
  495.  
  496. *****************************************************************************
  497. *
  498. *    AllocUDS            exec.library  MACRO                19 Dec 88
  499. *
  500. *    NAME:
  501. *         AllocUDS - Allocate memory for uninitialized data storage
  502. *
  503. *    SYNOPSIS:
  504. *      AllocUDS <BlockSize>
  505. *
  506. *                  Returns:  Start address of the memory block in A5.
  507. *                            Z-flag = 1 if fail.
  508. *                            Turns on reentrant programming mode.
  509. *
  510. *    FUNCTION:
  511. *         This macro is used to allocate memory for uninitialized data
  512. *          storage for reentrant programs. This macro should be invoked
  513. *          at the beginning of reentrant programs.
  514. *
  515. *         The value of <BlockSize> can be determined by equating <BlockSize>
  516. *          to DefDSPointer at the end of the program.
  517. *
  518. *         See also FreeUDS, DefDS.
  519. *
  520. *
  521. *    INPUTS:
  522. *         <BlockSize>    - Specifies number of bytes in the block.
  523. *
  524. *
  525.  
  526.  
  527. AllocUDS  MACRO
  528. *------------------------------; Start of AllocUDS macro.
  529.                                ; Put block size in D0.
  530.      MOVE.L #\1,D0
  531.      CLR.L D1                  ; Accept any memory.
  532.      NOLIST
  533.                                ; Define _AbsExecBase and _LVOAllocMem if
  534.      IFND _AbsExecBase         ;  they have not yet been defined.
  535.      LIST
  536.      XREF _AbsExecBase
  537.      NOLIST
  538.      ENDC
  539.      IFND _LVOAllocMem
  540.      LIST
  541.      XREF _LVOAllocMem
  542.      NOLIST
  543.      ENDC
  544.      LIST
  545.      MOVE.L _AbsExecBase,A6
  546.      JSR _LVOAllocMem(A6)      ; Allocate the UDS memory block.
  547.      MOVEA.L D0,A5             ; Make A5 point to the UDS memory.
  548.      OnReEntrant               ; Turn on reentrant programming.
  549.      TST.L D0                  ; Make the zero flag indicate failure.
  550. *------------------------------; End of AllocUDS macro.
  551.      ENDM
  552.  
  553. *****************************************************************************
  554.  
  555. *****************************************************************************
  556. *
  557. *    AvailMem            exec.library  MACRO                  27 Dec 88
  558. *
  559. *    NAME:
  560. *         AvailMem - Get size of memory available given certain requirements
  561. *
  562. *    SYNOPSIS:
  563. *         AvailMem [ PUBLIC!CHIP!FAST ]
  564. *
  565. *                  Returns:  Size of available memory in D0.
  566. *
  567. *    FUNCTION:
  568. *         This macro returns the size of available memory given certain
  569. *          requirements. Specify PUBLIC if the memory is to be accessible by
  570. *          other tasks; otherwise, it will be private. Specify CHIP if the
  571. *          memory should be accessible by the custom chips; otherwise, it
  572. *          will try to use fast memory, if available. Specify FAST if it must
  573. *          be non-chip memory.
  574. *
  575. *    INPUTS:
  576. *         [PUBLIC!CHIP!FAST]  - Type PUBLIC, CHIP, and/or FAST, separated
  577. *                                by a "!".
  578. *
  579. *         exec.library.LP      - Must have been defined by invoking the
  580. *                                 "OpenLib exec.library" macro command.
  581. *
  582. *    RESULTS:
  583. *         size of free memory  - Returned in D0.
  584. *
  585.  
  586.  
  587. AvailMem    MACRO
  588. *------------------------------; Start of AvailMem macro.
  589.      NOLIST
  590.      IFEQ NARG                 ; If \1 is not given, then
  591.      LIST
  592.      CLR.L D1                  ; Accept any available memory.
  593.      NOLIST
  594.      ENDC
  595.      IFEQ NARG-1               ; If \1 is given, then
  596. PUBLIC SET 1
  597. CHIP   SET 2
  598. FAST   SET 4
  599.      LIST
  600.      MOVEQ #\1,D1              ; Set the appropriate bits in D1.
  601.      NOLIST
  602.      ENDC
  603.      LIST
  604.      CallLib AvailMem,exec     ; Call AvailMem.
  605. *------------------------------; End of AvailMem macro.
  606.      ENDM
  607.  
  608. *****************************************************************************
  609.  
  610. *****************************************************************************
  611. *
  612. *    Close                  dos.library  MACRO                13 Sept 88
  613. *
  614. *    NAME:
  615. *         Close  - Close a directory or file.
  616. *
  617. *    SYNOPSIS:
  618. *         Close <FileHandleName>
  619. *
  620. *                  Returns:  Nothing.
  621. *
  622. *    FUNCTION:
  623. *         This macro closes a directory or file.
  624. *
  625. *         See also Open.
  626. *
  627. *    INPUTS:
  628. *         <FileHandleName> - The name of the file to be removed.
  629. *
  630. *         dos.library.LP   - Must have been defined by invoking the
  631. *                             "OpenLib dos.library" macro command.
  632. *
  633.  
  634.  
  635. Close          MACRO
  636. *------------------------------; Start of Close macro.
  637.                                ; Put the file handle in D1.
  638.      NOLIST
  639.      IFEQ ReEntrant-1
  640.      LIST
  641.      MOVE.L \1(A5),D1
  642.      NOLIST
  643.      ENDC
  644.      IFNE ReEntrant-1
  645.      LIST
  646.      MOVE.L \1,D1
  647.      NOLIST
  648.      ENDC
  649.      LIST
  650.      CallLib Close,dos         ; Call Close to remove the file.
  651. *------------------------------; End of Close macro.
  652.      ENDM
  653.  
  654. *****************************************************************************
  655.  
  656. *****************************************************************************
  657. *
  658. *    CreateDir           dos.library  MACRO                 19 Dec 88
  659. *
  660. *    NAME:
  661. *         CreateDir  - Create a new directory.
  662. *
  663. *    SYNOPSIS:
  664. *         CreateDir <DirLockName>,D,<DirName>
  665. *         CreateDir <DirLockName>,I,<PointerToDirName>
  666. *         CreateDir <DirLockName>,R,D1
  667. *
  668. *                  Returns:  Shared read lock in D0 and at <DirLockName>.
  669. *                            Z-flag = 1 if fail.
  670. *
  671. *    FUNCTION:
  672. *         This macro creates a new directory with the name specified as
  673. *          <DirName>.  The directory name is either specified directly as
  674. *          <DirName>, or indirectly as a string pointed to by D1 or by
  675. *          <PointerToDirName>.  It returns a shared read lock in D0 and at
  676. *          <DirLockName>.  If it is not successful, it will return a shared
  677. *          read lock of zero and set the zero flag.
  678. *
  679. *    INPUTS:
  680. *         "D","I" or "R"      - Indicates "direct", "indirect", or "register"
  681. *                                mode for the third argument.
  682. *
  683. *         <PointerToDirName>, - Pointer to a null-terminated directory name
  684. *         D1, or <DirName>       string or the directory name itself.
  685. *
  686. *         <DirLockName>       - The name you want the read lock to be called.
  687. *
  688. *         dos.library.LP      - Must have been defined by invoking the
  689. *                                "OpenLib dos.library" macro command.
  690. *
  691. *    RESULTS:
  692. *         read lock   - Returned in D0 and in memory at the address
  693. *                        labeled "<DirLockName>".
  694. *
  695. *         fail        - Zero flag = true if failed, false if o.k.
  696. *
  697.  
  698.  
  699. CreateDir   MACRO
  700. *------------------------------; Start of CreateDir macro.
  701.      NOLIST
  702.      IFC '\2','I'              ; If <PointerToDirName> is specified, then
  703.      LIST
  704.                                ; Put <PointerToDirName> in D1.
  705.      MOVE.L #\3,D1
  706.      NOLIST
  707.      IFEQ ReEntrant-1
  708.      LIST
  709.      ADD.L A5,D1
  710.      NOLIST
  711.      ENDC
  712.      ENDC
  713.      IFC '\2','D'              ; If <DirName> is specified, then
  714.      LIST
  715.                                ; Make D1 point to the directory name string.
  716.      MOVE.L #\3.str,D1
  717.      NOLIST
  718.      IFND \3.str               ; Unless it was previously defined,
  719.      LIST
  720.      SECTION DataSection,DATA  ; The ASCII directory name string goes here.
  721. \3.str:
  722.      DC.B '\3',0
  723.      CNOP 0,2
  724.      SECTION CodeSection,CODE
  725.      NOLIST
  726.      ENDC
  727.      ENDC
  728.      LIST
  729.      CallLib CreateDir,dos     ; Call CreateDir to create the directory.
  730.                                ; Put the dir read lock at <DirLockName>.
  731.      NOLIST
  732.      IFEQ ReEntrant-1
  733.      LIST
  734.      DefDS \1,1
  735.      MOVE.L D0,\1(A5)
  736.      NOLIST
  737.      ENDC
  738.      IFNE ReEntrant-1
  739.      LIST
  740.      MOVE.L D0,\1
  741.      DS_BSS \1,1,.L
  742.      NOLIST
  743.      ENDC
  744.      LIST
  745.      TST.L D0                  ; Make the zero flag indicate failure.
  746. *------------------------------; End of CreateDir macro.
  747.      ENDM
  748.  
  749. *****************************************************************************
  750.  
  751. *****************************************************************************
  752. *
  753. *    CurrentDir          dos.library  MACRO                 14 Sept 88
  754. *
  755. *    NAME:
  756. *         CurrentDir - Make the directory associated with a lock the current
  757. *                       directory.
  758. *
  759. *    SYNOPSIS:
  760. *         CurrentDir <NewDirLockName> [,<OldDirLockName>]
  761. *
  762. *                  Returns:  Old dir lock in D0 and at "OldDirLock" or at
  763. *                             <OldDirLockName> if it is specified.
  764. *                            Z-flag = 1 if the old dir is the root of the
  765. *                                        initial startup disk.
  766. *
  767. *    FUNCTION:
  768. *         This macro makes the directory associated with the <NewDirLockName>
  769. *          be the current directory. It returns a lock to the old directory
  770. *          in D0 and at the location "OldDirLock" or at "<OldDirLockName>" if
  771. *          "<OldDirLockName>" is specified. If the old directory was the root
  772. *          of the initial startup disk, the old-directory-lock will be zero
  773. *          and the zero flag will be set.
  774. *
  775. *         See also Lock, ParentDir.
  776. *
  777. *    INPUTS:
  778. *         <NewDirLockName> - This is the name of the directory lock which was
  779. *                             returned by the Lock macro.
  780. *
  781. *         <OldDirLockName> - The optional name you can specify for the old
  782. *                             directory lock.
  783. *
  784. *         dos.library.LP - Must have been defined by invoking the
  785. *                             "OpenLib dos.library" macro command.
  786. *
  787. *    RESULTS:
  788. *         old dir lock  - Returned in D0 and in memory at the address
  789. *                          labeled "OldDirLock" or "<OldDirLockName>".
  790. *
  791. *         old was root  - Zero flag = true if the old directory was the root.
  792. *
  793.  
  794.  
  795. CurrentDir  MACRO
  796. *------------------------------; Start of CurrentDir macro.
  797.                                ; Set up D1 for the _LVOCurrentDir function.
  798.      NOLIST
  799.      IFEQ ReEntrant-1
  800.      LIST
  801.      MOVE.L \1(A5),D1
  802.      NOLIST
  803.      ENDC
  804.      IFNE ReEntrant-1
  805.      LIST
  806.      MOVE.L \1,D1
  807.      NOLIST
  808.      ENDC
  809.      LIST
  810.      CallLib CurrentDir,dos    ; Call CurrentDir.
  811.      NOLIST
  812.      IFEQ NARG-2               ; If <OldDirLockName> is specified,
  813.      LIST
  814.                                ; Save the old dir lock under the specified
  815.                                ;  name.
  816.      NOLIST
  817.      IFEQ ReEntrant-1
  818.      LIST
  819.      DefDS \2,1
  820.      MOVE.L D0,\2(A5)
  821.      NOLIST
  822.      ENDC
  823.      IFNE ReEntrant-1
  824.      LIST
  825.      MOVE.L D0,\2
  826.      DS_BSS \2,1,.L
  827.      NOLIST
  828.      ENDC
  829.      ENDC
  830.      IFEQ NARG-1
  831.                                ; If <OldDirLockName> is not specified, then
  832.      IFEQ ReEntrant-1
  833.      LIST
  834.      DefDS OldDirLock,1
  835.      MOVE.L D0,OldDirLock(A5)  ; Save the old directory lock at "OldDirLock".
  836.      NOLIST
  837.      ENDC
  838.      IFNE ReEntrant-1
  839.      LIST
  840.      MOVE.L D0,OldDirLock      ; Save the old directory lock at "OldDirLock".
  841.      DS_BSS OldDirLock,1,.L
  842.      NOLIST
  843.      ENDC
  844.      ENDC
  845.      LIST
  846.      TST.L D0                  ; Make the zero flag indicate if old was root.
  847. *------------------------------; End of CurrentDir macro.
  848.      ENDM
  849.  
  850. *****************************************************************************
  851.  
  852. *****************************************************************************
  853. *
  854. *    DateStamp              dos.library  MACRO              14 Sept 88
  855. *
  856. *    NAME:
  857. *         DateStamp - Obtain the date and time in internal format
  858. *
  859. *    SYNOPSIS:
  860. *         DateStamp
  861. *
  862. *               Returns:  # of days since Jan. 1, 1978 at "Time.ds_Days"
  863. *                         # of minutes in day  at "Time.ds_Minute"
  864. *                         # if ticks in minute at "Time.ds_Tick"
  865. *
  866. *    FUNCTION:
  867. *         This macro returns the date and time in the form of three longwords
  868. *          at "Time.ds_Days", "Time.ds_Minute", and "Time.ds_Tick".
  869. *          Note that the number of ticks is rounded off to the nearest 50
  870. *          ticks (one second).
  871. *
  872. *    INPUTS:
  873. *         dos.library.LP   - Must have been defined by invoking the
  874. *                             "OpenLib dos.library" macro command.
  875. *
  876.  
  877.  
  878. DateStamp      MACRO
  879. *------------------------------; Start of DateStamp macro.
  880.      NOLIST
  881.      IFEQ ReEntrant-1
  882.      LIST
  883.      DefDS Time.ds_Days,1
  884.      DefDS Time.ds_Minute,1
  885.      DefDS Time.ds_Tick,1
  886.      NOLIST
  887.      ENDC
  888.      IFNE ReEntrant-1
  889.      LIST
  890.      DS_BSS Time.ds_Days,1,.L
  891.      DS_BSS Time.ds_Minute,1,.L
  892.      DS_BSS Time.ds_Tick,1,.L
  893.      NOLIST
  894.      ENDC
  895.      LIST
  896.      MOVE.L #Time.ds_Days,D1   ; Make D1 point to the date stamp buffer.
  897.      NOLIST
  898.      IFEQ ReEntrant-1
  899.      LIST
  900.      ADD.L A5,D1
  901.      NOLIST
  902.      ENDC
  903.      LIST
  904.      CallLib DateStamp,dos     ; Call DateStamp.
  905. *------------------------------; End of DateStamp macro.
  906.      ENDM
  907.  
  908. *****************************************************************************
  909.  
  910. *****************************************************************************
  911. *
  912. *    Delay                  dos.library  MACRO              10 Jan 88
  913. *
  914. *    NAME:
  915. *         Delay  - Delay a process for a specified time.
  916. *
  917. *    SYNOPSIS:
  918. *         Delay <timeout>
  919. *
  920. *                  Returns:  Nothing.
  921. *
  922. *    FUNCTION:
  923. *         This macro delays a process for a time specified by <timeout>.
  924. *          The delay time in units of one fiftieth of a second.
  925. *
  926. *         See also WaitForChar.
  927. *
  928. *    INPUTS:
  929. *         <timeout>        - The delay time in units of one fiftieth of a
  930. *                             second.
  931. *
  932. *         dos.library.LP   - Must have been defined by invoking the
  933. *                             "OpenLib dos.library" macro command.
  934. *
  935.  
  936.  
  937. Delay          MACRO
  938. *------------------------------; Start of Delay macro.
  939.                                ; Specify the timeout in D1.
  940.      MOVE.L #\1,D1
  941.      CallLib Delay,dos         ; Call Delay.
  942. *------------------------------; End of Delay macro.
  943.      ENDM
  944.  
  945. *****************************************************************************
  946.  
  947. *****************************************************************************
  948. *
  949. *    DeleteFile          dos.library  MACRO                 19 Dec 88
  950. *
  951. *    NAME:
  952. *         DeleteFile  - Delete a directory or file.
  953. *
  954. *    SYNOPSIS:
  955. *         DeleteFile D,<FileName>
  956. *         DeleteFile I,<PointerToFileName>
  957. *         DeleteFile R,D1
  958. *
  959. *                  Returns:  Z-flag = 1 if fail.
  960. *
  961. *    FUNCTION:
  962. *         This macro deletes a directory or file.  The file name is either
  963. *          specified directly as <FileName>, or indirectly as a string
  964. *          pointed to by D1 or by <PointerToFileName>.
  965. *
  966. *    INPUTS:
  967. *         "D","I" or "R"      - Indicates "direct", "indirect", or "register"
  968. *                                mode for the second argument.
  969. *
  970. *         <PointerToFileName> - Pointer to a null-terminated file name string
  971. *         or <FileName>          or the FileName itself.
  972. *
  973. *         dos.library.LP      - Must have been defined by invoking the
  974. *                                "OpenLib dos.library" macro command.
  975. *
  976.  
  977.  
  978. DeleteFile     MACRO
  979. *------------------------------; Start of DeleteFile macro.
  980.      NOLIST
  981.      IFC '\1','I'              ; If <PointerToFileName> is specified, then
  982.      LIST
  983.                                ; Put <PointerToFileName> in D1.
  984.      MOVE.L #\2,D1
  985.      NOLIST
  986.      IFEQ ReEntrant-1
  987.      LIST
  988.      ADD.L A5,D1
  989.      NOLIST
  990.      ENDC
  991.      ENDC
  992.      IFC '\1','D'              ; If <FileName> is specified, then
  993.      LIST
  994.                                ; Make D1 point to <FileName>.
  995.      MOVE.L #\2.str,D1
  996.      NOLIST
  997.      IFND \2.str               ; Unless it was previously defined,
  998.      LIST
  999.      SECTION DataSection,DATA  ; The ASCII <FileName> string goes here.
  1000. \2.str:
  1001.      DC.B '\2',0
  1002.      CNOP 0,2
  1003.      SECTION CodeSection,CODE
  1004.      NOLIST
  1005.      ENDC
  1006.      ENDC
  1007.      LIST
  1008.      CallLib DeleteFile,dos    ; Call DeleteFile to delete the file.
  1009.      TST.L D0                  ; Make the zero flag indicate failure.
  1010. *------------------------------; End of DeleteFile macro.
  1011.      ENDM
  1012.  
  1013. *****************************************************************************
  1014.  
  1015. *****************************************************************************
  1016. *
  1017. *    Disable                  MACRO                            9 Feb 89
  1018. *
  1019. *    NAME:
  1020. *         Disable - Disable all interrupts.
  1021. *
  1022. *    SYNOPSIS:
  1023. *         Disable
  1024. *
  1025. *    FUNCTION:
  1026. *         This macro disables all interrupts. It may be unsafe to leave
  1027. *          interrupts disabled for more than 250 microseconds.
  1028. *
  1029. *         See also Enable.
  1030. *
  1031.  
  1032. Disable   MACRO
  1033. *------------------------------; Start of Disable macro.
  1034.      NOLIST
  1035.      IFND _intena
  1036.      LIST
  1037.      XREF _intena
  1038.      NOLIST
  1039.      ENDC
  1040.      IFEQ ReEntrant-1
  1041.      LIST
  1042.         MOVE.L exec.library.ptr(A5),A6
  1043.      NOLIST
  1044.      ENDC
  1045.      IFNE ReEntrant-1
  1046.      LIST
  1047.         MOVE.L exec.library.ptr,A6
  1048.      NOLIST
  1049.      ENDC
  1050.      LIST
  1051.      MOVE.W #$4000,_intena
  1052.      ADDQ.B #1,$126(A6)        ; Increment IDNestCnt.
  1053. *------------------------------; End of Disable macro.
  1054.      ENDM
  1055.  
  1056. *****************************************************************************
  1057.  
  1058. *****************************************************************************
  1059. *
  1060. *    DoCLICmd            dos.library  MACRO                 14 Jan 88
  1061. *
  1062. *    NAME:
  1063. *         DoCLICmd  - Do a CLI command.
  1064. *
  1065. *    SYNOPSIS:
  1066. *         DoCLICmd <CmdBufferPtr> [,<OutputFileHandleName>]
  1067. *
  1068. *                  Returns:  Z-flag = 1 if fail.
  1069. *
  1070. *    FUNCTION:
  1071. *         This macro executes the command string pointed to by <CmdBufferPtr>
  1072. *          as a CLI command. If the optional <OutputFileHandleName> is
  1073. *          specified, the CLI command will send its data to the specified
  1074. *          file. Otherwise, output will go to the current window. If it is
  1075. *          not successful, it will set the zero flag.
  1076. *
  1077. *         See also Execute.
  1078. *
  1079. *    INPUTS:
  1080. *         <CmdBufferPtr>     - The pointer to the CLI command string to be
  1081. *                               executed.
  1082. *
  1083. *     <OutputFileHandleName> - The optional output file specification. Use
  1084. *                               the file handle name which was defined for
  1085. *                               the "Open" macro.
  1086. *
  1087. *         dos.library.LP     - Must have been defined by invoking the
  1088. *                               "OpenLib dos.library" macro command.
  1089. *
  1090. *    RESULTS:
  1091. *         fail        - Zero flag = true if failed, false if o.k.
  1092. *
  1093.  
  1094.  
  1095. DoCLICmd    MACRO
  1096. *------------------------------; Start of DoCLICmd macro.
  1097.      CLR.L D2                  ; Make D2 indicate "execute from command
  1098.                                ;  string only".
  1099.      NOLIST
  1100.      IFEQ NARG-2               ; If the output file handle is specified, then
  1101.      LIST
  1102.                                ; Make D3 indicate the output file handle.
  1103.      NOLIST
  1104.      IFEQ ReEntrant-1
  1105.      LIST
  1106.      MOVE.L \2(A5),D3
  1107.      NOLIST
  1108.      ENDC
  1109.      IFNE ReEntrant-1
  1110.      LIST
  1111.      MOVE.L \2,D3
  1112.      NOLIST
  1113.      ENDC
  1114.      ENDC
  1115.      IFEQ NARG-1               ; If no output file handle is specified, then
  1116.      LIST
  1117.      CLR.L D3                  ; Clear D3 so that output will go to the
  1118.                                ;  current window.
  1119.      NOLIST
  1120.      ENDC
  1121.      LIST
  1122.                                ; Make D1 point to the command buffer.
  1123.      MOVE.L #\1,D1
  1124.      NOLIST
  1125.      IFEQ ReEntrant-1
  1126.      LIST
  1127.      ADD.L A5,D1
  1128.      NOLIST
  1129.      ENDC
  1130.      LIST
  1131.      CallLib Execute,dos       ; Call Execute to do the CLI command.
  1132.      TST.L D0                  ; Make the zero flag indicate failure.
  1133. *------------------------------; End of DoCLICmd macro.
  1134.      ENDM
  1135.  
  1136. *****************************************************************************
  1137.  
  1138. *****************************************************************************
  1139. *
  1140. *    Enable                   MACRO                            9 Feb 89
  1141. *
  1142. *    NAME:
  1143. *         Enable - Enable interrupts.
  1144. *
  1145. *    SYNOPSIS:
  1146. *         Enable
  1147. *
  1148. *    FUNCTION:
  1149. *         This macro enables interrupts.
  1150. *
  1151. *         See also Disable.
  1152. *
  1153.  
  1154. Enable    MACRO
  1155. *------------------------------; Start of Enable macro.
  1156.      NOLIST
  1157.      IFEQ ReEntrant-1
  1158.      LIST
  1159.         MOVE.L exec.library.ptr(A5),A6
  1160.      NOLIST
  1161.      ENDC
  1162.      IFNE ReEntrant-1
  1163.      LIST
  1164.         MOVE.L exec.library.ptr,A6
  1165.      NOLIST
  1166.      ENDC
  1167.      LIST
  1168.      SUBQ.B #1,$126(A6)        ; Decrement IDNestCnt.
  1169.      BGE.S 5$
  1170.      MOVE.W #$C000,_intena
  1171. 5$:
  1172. *------------------------------; End of Enable macro.
  1173.      ENDM
  1174.  
  1175. *****************************************************************************
  1176.  
  1177. *****************************************************************************
  1178. *
  1179. *    Execute             dos.library  MACRO                 14 Sept 88
  1180. *
  1181. *    NAME:
  1182. *         Execute  - Execute CLI commands from a command file.
  1183. *
  1184. *    SYNOPSIS:
  1185. *         Execute <CmdFileHandleName> [,<OutputFileHandleName>]
  1186. *
  1187. *                  Returns:  Z-flag = 1 if fail.
  1188. *
  1189. *    FUNCTION:
  1190. *         This macro executes CLI commands from the command file specified
  1191. *          by <CmdFileHandleName>. If the optional <OutputFileHandleName> is
  1192. *          specified, the CLI command will send its data to the specified
  1193. *          file. Otherwise, output will go to the current window. If it is
  1194. *          not successful, it will set the zero flag.
  1195. *
  1196. *         See also DoCLICmd.
  1197. *
  1198. *    INPUTS:
  1199. *         <CmdFileHandleName> - The file handle name of the command file.
  1200. *                                Use the file handle name which was defined
  1201. *                                for the "Open" macro.
  1202. *
  1203. *      <OutputFileHandleName> - The optional output file specification. Use
  1204. *                                the file handle name which was defined for
  1205. *                                the "Open" macro.
  1206. *
  1207. *         dos.library.LP      - Must have been defined by invoking the
  1208. *                                "OpenLib dos.library" macro command.
  1209. *
  1210. *    RESULTS:
  1211. *         fail        - Zero flag = true if failed, false if o.k.
  1212. *
  1213.  
  1214.  
  1215. Execute     MACRO
  1216. *------------------------------; Start of Execute macro.
  1217.      MOVE.L #NullString,D1     ; Make D1 point to a null command string.
  1218.      NOLIST
  1219.      IFND NullString
  1220.      LIST
  1221.      SECTION DataSection,DATA
  1222. NullString:
  1223.      DC.B 0,0
  1224.      SECTION CodeSection,CODE
  1225.      NOLIST
  1226.      ENDC
  1227.      IFEQ NARG-2               ; If the output file handle is specified, then
  1228.      LIST
  1229.                                ; Make D3 indicate the output file handle.
  1230.      NOLIST
  1231.      IFEQ ReEntrant-1
  1232.      LIST
  1233.      MOVE.L \2(A5),D3
  1234.      NOLIST
  1235.      ENDC
  1236.      IFNE ReEntrant-1
  1237.      LIST
  1238.      MOVE.L \2,D3
  1239.      NOLIST
  1240.      ENDC
  1241.      ENDC
  1242.      IFEQ NARG-1               ; If no output file handle is specified, then
  1243.      LIST
  1244.      CLR.L D3                  ; Clear D3 so that output will go to the
  1245.                                ;  current window.
  1246.      NOLIST
  1247.      ENDC
  1248.      LIST
  1249.                                ; Put the command file handle in D2.
  1250.      NOLIST
  1251.      IFEQ ReEntrant-1
  1252.      LIST
  1253.      MOVE.L \1(A5),D2
  1254.      NOLIST
  1255.      ENDC
  1256.      IFNE ReEntrant-1
  1257.      LIST
  1258.      MOVE.L \1,D2
  1259.      NOLIST
  1260.      ENDC
  1261.      LIST
  1262.      CallLib Execute,dos       ; Call Execute.
  1263.      TST.L D0                  ; Make the zero flag indicate failure.
  1264. *------------------------------; End of Execute macro.
  1265.      ENDM
  1266.  
  1267. *****************************************************************************
  1268.  
  1269. *****************************************************************************
  1270. *
  1271. *    Exist               dos.library  MACRO                 Rev: 19 Dec 88
  1272. *
  1273. *    NAME:
  1274. *         Exist  - Find out if a directory or file exists.
  1275. *
  1276. *    SYNOPSIS:
  1277. *         Exist D,<FileName>
  1278. *         Exist I,<PointerToFileName>
  1279. *         Exist R,D1
  1280. *
  1281. *                  Returns:  Z-flag = 0 if it exists.
  1282. *                            Z-flag = 1 if non-existent.
  1283. *
  1284. *    FUNCTION:
  1285. *         This macro checks to see if a specified file or directory exists.
  1286. *          The file name is either specified directly as <FileName>, or
  1287. *          indirectly as a string pointed to by D1 or by <PointerToFileName>.
  1288. *
  1289. *         See also Lock.
  1290. *
  1291. *    INPUTS:
  1292. *         "D","I" or "R"      - Indicates "direct", "indirect", or "register"
  1293. *                                mode for the second argument.
  1294. *
  1295. *         <PointerToFileName> - Pointer to a null-terminated file name string
  1296. *         or <FileName>          or the FileName itself.
  1297. *
  1298. *         dos.library.LP      - Must have been defined by invoking the
  1299. *                                "OpenLib dos.library" macro command.
  1300. *
  1301. *    RESULTS:
  1302. *         existence   - Z-flag = 0 if it exists or = 1 if non-existent.
  1303. *
  1304.  
  1305.  
  1306. Exist       MACRO
  1307. *------------------------------; Start of Exist macro.
  1308.      MOVEQ #-2,D2              ; Make D2 indicate the read accessMode.
  1309.      NOLIST
  1310.      IFC '\1','I'              ; If <PointerToFileName> is specified, then
  1311.      LIST
  1312.                                ; Put <PointerToFileName> in D1.
  1313.      MOVE.L #\2,D1
  1314.      NOLIST
  1315.      IFEQ ReEntrant-1
  1316.      LIST
  1317.      ADD.L A5,D1
  1318.      NOLIST
  1319.      ENDC
  1320.      ENDC
  1321.      IFC '\1','D'              ; If <FileName> is specified, then
  1322.      LIST
  1323.                                ; Make D1 point to <FileName>.str .
  1324.      MOVE.L #\2.str,D1
  1325.      NOLIST
  1326.      IFND \2.str               ; Unless it was previously defined,
  1327.      LIST
  1328.      SECTION DataSection,DATA  ; The ASCII <FileName> string goes here.
  1329. \2.str:
  1330.      DC.B '\2',0
  1331.      CNOP 0,2
  1332.      SECTION CodeSection,CODE
  1333.      NOLIST
  1334.      ENDC
  1335.      ENDC
  1336.      LIST
  1337.      CallLib Lock,dos          ; Call Lock to get a lock on <FileName>.
  1338.      MOVE.L D0,-(A7)           ; Save the lock which indicates existence.
  1339.      MOVE.L D0,D1              ; Unlock the file.
  1340.      CallLib UnLock,dos
  1341.      MOVE.L (A7)+,D0           ; Get the lock back.
  1342.      TST.L D0                  ; Make the zero flag indicate existence.
  1343. *------------------------------; End of Exist macro.
  1344.      ENDM
  1345.  
  1346. *****************************************************************************
  1347.  
  1348. *****************************************************************************
  1349. *
  1350. *    FindTask           exec.library  MACRO                 19 Dec 88
  1351. *
  1352. *    NAME:
  1353. *         FindTask  - Find a task with a given name or find oneself.
  1354. *
  1355. *    SYNOPSIS:
  1356. *         FindTask Self,<TaskStructPtrName>
  1357. *         FindTask D,<TaskName>,<TaskStructPtrName>
  1358. *         FindTask I,<PointerToTaskName>,<TaskStructPtrName>
  1359. *         FindTask R,A1,<TaskStructPtrName>
  1360. *
  1361. *                  Returns:  Pointer to the task structure in D0 and at
  1362. *                            <TaskStructPtrName>.
  1363. *
  1364. *    FUNCTION:
  1365. *         This macro returns a pointer to the specified task control
  1366. *          structure. The file name is either specified as "Self", specified
  1367. *          directly as <TaskName>, or indirectly as a string pointed to by
  1368. *          either <PointerToTaskName> or A1.
  1369. *
  1370. *         The pointer is returned in D0 and at <TaskStructPtrName>. This
  1371. *          macro will create "<TaskStructPtrName>" if it does not already
  1372. *          exists.
  1373. *
  1374. *    INPUTS:
  1375. *         "Self"              - Specifies the current task.
  1376. *
  1377. *         "D","I" or "R"      - Indicates "direct", "indirect", or "register"
  1378. *                                mode for the second argument.
  1379. *
  1380. *         <PointerToTaskName> - Pointer to a null-terminated task name string
  1381. *         or <TaskName>          or the task name itself.
  1382. *
  1383. *         <TaskStructPtrName> - The name you want the pointer to the task
  1384. *                                structure to be called.
  1385. *
  1386. *         dos.library.LP      - Must have been defined by invoking the
  1387. *                                "OpenLib dos.library" macro command.
  1388. *
  1389. *    RESULTS:
  1390. *         task struct pointer - Returned in D0 and in memory at the address
  1391. *                                labeled "<TaskStructPtrName>".
  1392. *
  1393.  
  1394.  
  1395. FindTask    MACRO
  1396. *------------------------------; Start of FindTask macro.
  1397.      NOLIST
  1398.      IFC '\1','I'              ; If <PointerToTaskName> is specified, then
  1399.      LIST
  1400.                                ; Put <PointerToTaskName> in A1.
  1401.      MOVEA.L #\2,A1
  1402.      NOLIST
  1403.      IFEQ ReEntrant-1
  1404.      LIST
  1405.      ADDA.L A5,A1
  1406.      NOLIST
  1407.      ENDC
  1408.      ENDC
  1409.      IFC '\1','D'              ; If <TaskName> is specified, then
  1410.      LIST
  1411.                                ; Make A1 point to the task name string.
  1412.      MOVEA.L #\2.str,A1
  1413.      NOLIST
  1414.      IFND \2.str               ; Unless it was previously defined,
  1415.      LIST
  1416.      SECTION DataSection,DATA  ; The ASCII <TaskName> string goes here.
  1417. \2.str:
  1418.      DC.B '\2',0
  1419.      CNOP 0,2
  1420.      SECTION CodeSection,CODE
  1421.      NOLIST
  1422.      ENDC
  1423.      ENDC
  1424.      IFC '\1','Self'           ; If "Self" is specified, then
  1425.      LIST
  1426.      SUBA.L A1,A1              ; Clear A1 to indicate "Self".
  1427.      NOLIST
  1428.      ENDC
  1429.      LIST
  1430.      CallLib FindTask,exec     ; Call FindTask.
  1431.                                ; Put the pointer to the task structure at
  1432.                                ;  <TaskStructPtrName>.
  1433.      NOLIST
  1434.      IFC '\1','Self'
  1435.      IFEQ ReEntrant-1
  1436.      LIST
  1437.      DefDS \2,1
  1438.      MOVE.L D0,\2(A5)
  1439.      NOLIST
  1440.      ENDC
  1441.      IFNE ReEntrant-1
  1442.      LIST
  1443.      DS_BSS \2,1,.L
  1444.      MOVE.L D0,\2
  1445.      NOLIST
  1446.      ENDC
  1447.      ENDC
  1448.      IFNC '\1','Self'
  1449.      IFEQ ReEntrant-1
  1450.      LIST
  1451.      DefDS \3,1
  1452.      MOVE.L D0,\3(A5)
  1453.      NOLIST
  1454.      ENDC
  1455.      IFNE ReEntrant-1
  1456.      LIST
  1457.      DS_BSS \3,1,.L
  1458.      MOVE.L D0,\3
  1459.      NOLIST
  1460.      ENDC
  1461.      ENDC
  1462.      LIST
  1463. *------------------------------; End of FindTask macro.
  1464.      ENDM
  1465.  
  1466. *****************************************************************************
  1467.  
  1468. *****************************************************************************
  1469. *
  1470. *    FreeMem             exec.library  MACRO                14 Sept 88
  1471. *
  1472. *    NAME:
  1473. *         FreeMem - De-allocate memory
  1474. *
  1475. *    SYNOPSIS:
  1476. *         FreeMem <MemBlockName>
  1477. *
  1478. *                  Returns:  Nothing.
  1479. *
  1480. *    FUNCTION:
  1481. *         This macro frees a block of memory which was previously allocated
  1482. *          using the AllocMem macro.
  1483. *
  1484. *    INPUTS:
  1485. *         <MemBlockName>.Adr   - Location where the pointer to the memory
  1486. *                                 block is stored. This was created by the
  1487. *                                 AllocMem macro.
  1488. *
  1489. *         <MemBlockName>.Size  - Location where the size of the memory
  1490. *                                 block is stored. This was created by the
  1491. *                                 AllocMem macro.
  1492. *
  1493. *         exec.library.LP      - Must have been defined by invoking the
  1494. *                                 "OpenLib exec.library" macro command.
  1495. *
  1496.  
  1497.  
  1498. FreeMem     MACRO
  1499. *------------------------------; Start of FreeMem macro.
  1500.                                ; Make A1 point to the memory block start
  1501.                                ;  and put the block size in D0.
  1502.      NOLIST
  1503.      IFEQ ReEntrant-1
  1504.      LIST
  1505.      MOVEA.L \1.Adr(A5),A1
  1506.      MOVE.L \1.Size(A5),D0
  1507.      NOLIST
  1508.      ENDC
  1509.      IFNE ReEntrant-1
  1510.      LIST
  1511.      MOVEA.L \1.Adr,A1
  1512.      MOVE.L \1.Size,D0
  1513.      NOLIST
  1514.      ENDC
  1515.      LIST
  1516.      CallLib FreeMem,exec      ; Call FreeMem.
  1517. *------------------------------; End of FreeMem macro.
  1518.      ENDM
  1519.  
  1520. *****************************************************************************
  1521.  
  1522. *****************************************************************************
  1523. *
  1524. *    FreeUDS             exec.library  MACRO                25 Dec 88
  1525. *
  1526. *    NAME:
  1527. *         FreeUDS - Free memory which was allocated by AllocUDS
  1528. *
  1529. *    SYNOPSIS:
  1530. *      FreeUDS <BlockSize>
  1531. *
  1532. *                  Returns:  Nothing.
  1533. *
  1534. *    FUNCTION:
  1535. *         This macro is used to free memory used for uninitialized data
  1536. *          storage for reentrant programs. This macro should be invoked
  1537. *          at the end of reentrant programs.
  1538. *
  1539. *         The value of <BlockSize> should be the same as that used by
  1540. *          the AllocUDS macro.
  1541. *
  1542. *
  1543. *    INPUTS:
  1544. *         <BlockSize>    - Specifies number of bytes in the block.
  1545. *
  1546. *
  1547.  
  1548.  
  1549. FreeUDS   MACRO
  1550. *------------------------------; Start of FreeUDS macro.
  1551.      MOVEA.L A5,A1
  1552.      MOVE.L #\1,D0
  1553.      NOLIST                    ; Define _LVOAllocMem if not already defined.
  1554.      IFND _LVOFreeMem
  1555.      LIST
  1556.      XREF _LVOFreeMem
  1557.      NOLIST
  1558.      ENDC
  1559.      LIST
  1560.      MOVE.L _AbsExecBase,A6
  1561.      JSR _LVOFreeMem(A6)       ; Allocate the UDS memory block.
  1562. *------------------------------; End of FreeUDS macro.
  1563.      ENDM
  1564.  
  1565. *****************************************************************************
  1566.  
  1567. *****************************************************************************
  1568. *
  1569. *    GetPrefs            intuition.library  MACRO           14 Sept 88
  1570. *
  1571. *    NAME:
  1572. *         GetPrefs  - Get the preference settings.
  1573. *
  1574. *    SYNOPSIS:
  1575. *         GetPrefs I,<MemBlockName>
  1576. *
  1577. *         GetPrefs D,<BufferStartAddr>
  1578. *         GetPrefs D,<BufferStartAddr>,<BufferSize>
  1579. *
  1580. *                  Returns:  Preference settings in the buffer.
  1581. *
  1582. *    FUNCTION:
  1583. *         This macro gets the preferences data and puts it into a buffer.
  1584. *          The buffer is either specified indirectly by a vector located at
  1585. *          <MemBlockName>.Adr or directly by <BufferStartAddr>.
  1586. *
  1587. *         If no third argument is given, and <BufferStartAddr> is specified,
  1588. *          the label "<BufferStartAddr>End" must exist one byte past the end
  1589. *          of the buffer.
  1590. *
  1591. *         If no third argument is given, and <MemBlockName> is specified,
  1592. *          the buffer size must be specified in "<MemBlockName>.Size"
  1593. *          The AllocMem macro takes care of this.
  1594. *
  1595. *    INPUTS:
  1596. *         "D" or "I"           - Indicates "direct" or "indirect" mode for
  1597. *                                 the second argument.
  1598. *
  1599. *         <BufferStartAddr>    - Defined for the start of the buffer.
  1600. *
  1601. *         <MemBlockName>.Adr   - Location where the pointer to the memory
  1602. *                                 block is stored. This was created by the
  1603. *                                 AllocMem macro.
  1604. *
  1605. *         buffer start address - Specified as <BufferStartAddr>, or at
  1606. *                                 <MemBlockName>.Adr
  1607. *
  1608. *         buffer size         - Specified as <BufferSize>, or at
  1609. *                                <MemBlockName>.Size, or as <BufferStartAddr>
  1610. *                                minus <BufferStartAddr>End.
  1611. *
  1612. *         intuition.library.LP - Must have been defined by invoking the
  1613. *                                 "OpenLib intuition.library" macro command.
  1614. *
  1615. *    RESULTS:
  1616. *         preferences data   - Returned in the buffer.
  1617. *
  1618.  
  1619.  
  1620. GetPrefs    MACRO
  1621. *------------------------------; Start of GetPrefs macro.
  1622.      NOLIST
  1623.      IFC '\1','D'              ; If <BufferStartAddr> is specified, then
  1624.      LIST
  1625.                                ; Make A0 point to the start of the buffer.
  1626.      MOVE.L #\2,A0
  1627.      NOLIST
  1628.      IFEQ NARG-2               ; If <BufferSize> is given, then
  1629.      LIST
  1630.                                ; Put <BufferSize> in D0.
  1631.      MOVE.L #\3,D0
  1632.      NOLIST
  1633.      ENDC
  1634.      IFEQ NARG-2               ; If there is no third argument, then
  1635.      LIST
  1636.                                ; Calculate buffer size as
  1637.                                ;  <BufferStartAddr>End minus
  1638.                                ;  <BufferStartAddr>. Put it in D0.
  1639.      MOVE.L \2End-\2,D0
  1640.      NOLIST
  1641.      ENDC
  1642.      ENDC
  1643.      IFNC '\1','I'             ; If <MemBlockName> is specified, then
  1644.      LIST
  1645.                                ; Get the buffer start address from
  1646.                                ;  <MemBlockName>.Adr , and get the buffer
  1647.                                ; Size from <MemBlockName>.Size
  1648.      NOLIST
  1649.      IFEQ ReEntrant-1
  1650.      LIST
  1651.      MOVE.L \2.Adr(A5),A0
  1652.      MOVE.L \2.Size(A5),D0
  1653.      NOLIST
  1654.      ENDC
  1655.      IFNE ReEntrant-1
  1656.      LIST
  1657.      MOVE.L \2.Adr,A0
  1658.      MOVE.L \2.Size,D0
  1659.      NOLIST
  1660.      ENDC
  1661.      ENDC
  1662.      LIST
  1663.                                ; Call GetPrefs.
  1664.      CallLib GetPrefs,intuition
  1665. *------------------------------; End of GetPrefs macro.
  1666.      ENDM
  1667.  
  1668. *****************************************************************************
  1669.  
  1670. *****************************************************************************
  1671. *
  1672. *    GetStdIn            dos.library  MACRO                   14 Sept 88
  1673. *
  1674. *    NAME:
  1675. *         GetStdIn - Get a file handle for the program's initial output.
  1676. *
  1677. *    SYNOPSIS:
  1678. *         GetStdIn
  1679. *                  Returns:  File handle in D0 and at StdIn.
  1680. *
  1681. *    FUNCTION:
  1682. *         This macro returns a file handle for the program's initial input.
  1683. *          This file handle will usually be associated with the CLI window,
  1684. *          unless input was redirected from the command line.
  1685. *
  1686. *    INPUTS:
  1687. *         dos.library.LP  - Must have been defined by invoking the
  1688. *                             "OpenLib dos.library" macro command.
  1689. *
  1690. *    RESULTS:
  1691. *         file handle - Returned in D0 and in memory at the address
  1692. *                        labeled "StdIn".
  1693. *
  1694. *
  1695.  
  1696.  
  1697. GetStdIn    MACRO
  1698. *------------------------------; Start of GetStdIn macro.
  1699.      CallLib Input,dos         ; Call Input.
  1700.      NOLIST
  1701.      IFEQ ReEntrant-1
  1702.      LIST
  1703.      DefDS StdIn,1
  1704.      MOVE.L D0,StdIn(A5)       ; Save the file handle at StdIn.
  1705.      NOLIST
  1706.      ENDC
  1707.      IFNE ReEntrant-1
  1708.      LIST
  1709.      DS_BSS StdIn,1,.L
  1710.      MOVE.L D0,StdIn           ; Save the file handle at StdIn.
  1711.      NOLIST
  1712.      ENDC
  1713.      LIST
  1714. *------------------------------; End of GetStdIn macro.
  1715.      ENDM
  1716.  
  1717. *****************************************************************************
  1718.  
  1719. *****************************************************************************
  1720. *
  1721. *    GetStdOut           dos.library  MACRO                   14 Sept 88
  1722. *
  1723. *    NAME:
  1724. *         GetStdOut - Get a file handle for the program's initial output.
  1725. *
  1726. *    SYNOPSIS:
  1727. *         GetStdOut
  1728. *                  Returns:  File handle in D0 and at StdOut.
  1729. *
  1730. *    FUNCTION:
  1731. *         This macro returns a file handle for the program's initial output.
  1732. *          This file handle will usually be associated with the CLI window,
  1733. *          unless output was redirected from the command line.
  1734. *
  1735. *    INPUTS:
  1736. *         dos.library.LP  - Must have been defined by invoking the
  1737. *                             "OpenLib dos.library" macro command.
  1738. *
  1739. *    RESULTS:
  1740. *         file handle - Returned in D0 and in memory at the address
  1741. *                        labeled "StdOut".
  1742. *
  1743. *
  1744.  
  1745.  
  1746. GetStdOut   MACRO
  1747. *------------------------------; Start of GetStdOut macro.
  1748.      CallLib Output,dos        ; Call Output.
  1749.      NOLIST
  1750.      IFEQ ReEntrant-1
  1751.      LIST
  1752.      DefDS StdOut,1
  1753.      MOVE.L D0,StdOut(A5)      ; Save the file handle at StdOut.
  1754.      NOLIST
  1755.      ENDC
  1756.      IFNE ReEntrant-1
  1757.      LIST
  1758.      DS_BSS StdOut,1,.L
  1759.      MOVE.L D0,StdOut          ; Save the file handle at StdOut.
  1760.      NOLIST
  1761.      ENDC
  1762.      LIST
  1763. *------------------------------; End of GetStdOut macro.
  1764.      ENDM
  1765.  
  1766. *****************************************************************************
  1767.  
  1768. *****************************************************************************
  1769. *
  1770. *    IoErr                  dos.library  MACRO              18 Sept 88
  1771. *
  1772. *    NAME:
  1773. *         IoErr - Obtain the error code for the I/O error condition.
  1774. *
  1775. *    SYNOPSIS:
  1776. *         IoErr
  1777. *
  1778. *               Returns:  I/O error code in D0 and at IoErrCode.
  1779. *
  1780. *    FUNCTION:
  1781. *         This macro returns the I/O error code in D0 and at IoErrCode.
  1782. *
  1783. *    INPUTS:
  1784. *         dos.library.LP   - Must have been defined by invoking the
  1785. *                             "OpenLib dos.library" macro command.
  1786. *
  1787.  
  1788.  
  1789. IoErr          MACRO
  1790. *------------------------------; Start of IoErr macro.
  1791.      CallLib IoErr,dos         ; Call IoErr.
  1792.      NOLIST
  1793.      IFEQ ReEntrant-1
  1794.      LIST
  1795.      DefDS IoErrCode,1         ; Save error code at IoErrCode
  1796.      MOVE.L D0,IoErrCode(A5)
  1797.      NOLIST
  1798.      ENDC
  1799.      IFNE ReEntrant-1
  1800.      LIST
  1801.      DS_BSS IoErrCode,1,.L     ; Save error code at IoErrCode
  1802.      MOVE.L D0,IoErrCode
  1803.      NOLIST
  1804.      ENDC
  1805.      LIST
  1806. *------------------------------; End of IoErr macro.
  1807.      ENDM
  1808.  
  1809. *****************************************************************************
  1810.  
  1811. *****************************************************************************
  1812. *
  1813. *    Lock                dos.library  MACRO                 19 Dec 88
  1814. *
  1815. *    NAME:
  1816. *         Lock  - Obtain a lock on a directory or file.
  1817. *
  1818. *    SYNOPSIS:
  1819. *         Lock D,<FileName>,<LockName>,read | write
  1820. *         Lock I,<PointerToFileName>,<LockName>,read | write
  1821. *         Lock R,D1,<LockName>,read | write
  1822. *
  1823. *                  Returns:  Lock in D0 and at <LockName>.
  1824. *                            Z-flag = 1 if fail.
  1825. *
  1826. *    FUNCTION:
  1827. *         This macro returns a lock for a file or directory.  The file name
  1828. *          is either specified directly as <FileName>, or indirectly as a
  1829. *          string pointed to by D1 or by <PointerToFileName>.  If it is not
  1830. *          successful, it will return a file handle of zero and set the zero
  1831. *          flag.
  1832. *
  1833. *         See also UnLock.
  1834. *
  1835. *    INPUTS:
  1836. *         "D","I" or "R"      - Indicates "direct", "indirect", or "register"
  1837. *                                mode for the second argument.
  1838. *
  1839. *         <PointerToFileName> - Pointer to a null-terminated file name string
  1840. *         or <FileName>          or the FileName itself.
  1841. *
  1842. *         <LockName>     - The name you want the lock to be called.
  1843. *
  1844. *         read | write   - Must specify whether the file is a shared read
  1845. *                           lock or an exclusive write lock. Must be lower
  1846. *                           case.
  1847. *
  1848. *         dos.library.LP - Must have been defined by invoking the
  1849. *                             "OpenLib dos.library" macro command.
  1850. *
  1851. *    RESULTS:
  1852. *         file lock - Returned in D0 and in memory at the address
  1853. *                      labeled "<LockName>".
  1854. *
  1855. *         fail      - Zero flag = true if failed, false if o.k.
  1856. *
  1857.  
  1858.  
  1859. Lock        MACRO
  1860. *------------------------------; Start of Lock macro.
  1861.      NOLIST
  1862.      IFC '\4','read'
  1863.      LIST
  1864.      MOVEQ #-2,D2              ; Make D2 indicate the read accessMode.
  1865.      NOLIST
  1866.      ENDC
  1867.      IFC '\4','write'
  1868.      LIST
  1869.      MOVEQ #-1,D2              ; Make D2 indicate the write accessMode.
  1870.      NOLIST
  1871.      ENDC
  1872.      IFC '\1','I'              ; If <PointerToFileName> is specified, then
  1873.      LIST
  1874.                                ; Put <PointerToFileName> in D1.
  1875.      MOVE.L #\2,D1
  1876.      NOLIST
  1877.      IFEQ ReEntrant-1
  1878.      LIST
  1879.      ADD.L A5,D1
  1880.      NOLIST
  1881.      ENDC
  1882.      ENDC
  1883.      IFC '\1','D'              ; If <FileName> is specified, then
  1884.      LIST
  1885.                                ; Make D1 point to <FileName>.str .
  1886.      MOVE.L #\2.str,D1
  1887.      NOLIST
  1888.      IFND \2.str               ; Unless it was previously defined,
  1889.      LIST
  1890.      SECTION DataSection,DATA  ; The ASCII <FileName> string goes here.
  1891. \2.str:
  1892.      DC.B '\2',0
  1893.      CNOP 0,2
  1894.      SECTION CodeSection,CODE
  1895.      NOLIST
  1896.      ENDC
  1897.      ENDC
  1898.      LIST
  1899.      CallLib Lock,dos          ; Call Lock to get a lock on <FileName>.
  1900.                                ; Put the lock at <LockName>.
  1901.      NOLIST
  1902.      IFEQ ReEntrant-1
  1903.      LIST
  1904.      DefDS \3,1
  1905.      MOVE.L D0,\3(A5)
  1906.      NOLIST
  1907.      ENDC
  1908.      IFNE ReEntrant-1
  1909.      LIST
  1910.      DS_BSS \3,1,.L
  1911.      MOVE.L D0,\3
  1912.      NOLIST
  1913.      ENDC
  1914.      LIST
  1915.      TST.L D0                  ; Make the zero flag indicate failure.
  1916. *------------------------------; End of Lock macro.
  1917.      ENDM
  1918.  
  1919. *****************************************************************************
  1920.  
  1921. *****************************************************************************
  1922. *
  1923. *    Open                dos.library  MACRO                 19 Dec 88
  1924. *
  1925. *    NAME:
  1926. *         Open  - Open a file.
  1927. *
  1928. *    SYNOPSIS:
  1929. *         Open D,<FileName>,<FileHandleName> [,new | read | r/w]
  1930. *                                            [or with D0 = 0 if new]
  1931. *
  1932. *         Open I,<PointerToFileName>,<FileHandleName> [,new | read | r/w]
  1933. *                                                     [or with D0 = 0 if new]
  1934. *
  1935. *         Open R,D1,<FileHandleName> [,new | read | r/w]
  1936. *                                    [or with D0 = 0 if new]
  1937. *
  1938. *                  Returns:  File handle in D0 and at <FileHandleName>.
  1939. *                            Z-flag = 1 if fail.
  1940. *
  1941. *    FUNCTION:
  1942. *         This macro returns a file handle for a file.  The file name is
  1943. *          either specified directly as <FileName>, or indirectly as a string
  1944. *          pointed to by D1 or by <PointerToFileName>.
  1945. *
  1946. *         If it is not successful, it will return a file handle of zero and
  1947. *          set the zero flag.
  1948. *
  1949. *         See also Close.
  1950. *
  1951. *    INPUTS:
  1952. *         "D","I" or "R"      - Indicates "direct", "indirect", or "register"
  1953. *                                mode for the second argument.
  1954. *
  1955. *         <PointerToFileName> - Pointer to a null-terminated file name string
  1956. *         or <FileName>          or the FileName itself.
  1957. *
  1958. *         <FileHandleName> - The name you want the file handle to be called.
  1959. *
  1960. *         new | read | r/w - Specifys whether a new file should be created or
  1961. *                             an existing file should be used. For existing
  1962. *                             files, "read" indicates that a shared read lock
  1963. *                             is needed, "r/w" indicates that an exclusive
  1964. *                             lock is needed. Must be lower case.
  1965. *
  1966. *         D0 = 0 if new    - If new, read, or r/w is not specified, D0 tells
  1967. *                             the macro whether the file to be opened is a
  1968. *                             new file (D0 = 0) or existing r/w (D0 not 0).
  1969. *                             Use the Lock macro to establish D0.
  1970. *
  1971. *         dos.library.LP   - Must have been defined by invoking the
  1972. *                             "OpenLib dos.library" macro command.
  1973. *
  1974. *    RESULTS:
  1975. *         file handle - Returned in D0 and in memory at the address
  1976. *                        labeled "<FileHandleName>".
  1977. *
  1978. *         fail        - Zero flag = true if failed, false if o.k.
  1979. *
  1980.  
  1981.  
  1982. Open        MACRO
  1983. *------------------------------; Start of Open macro.
  1984.      NOLIST
  1985.      IFEQ NARG-4               ; If new, read, or r/w is specified, make D2
  1986.                                ;  indicate the accessMode accordingly.
  1987.      IFC '\4','new'
  1988.      LIST
  1989.      MOVE.L #1006,D2           ; Make D2 indicate "new" access mode.
  1990.      NOLIST
  1991.      ENDC
  1992.      IFC '\4','read'
  1993.      LIST
  1994.      MOVE.L #1005,D2           ; Make D2 indicate "read" access mode.
  1995.      NOLIST
  1996.      ENDC
  1997.      IFC '\4','r/w'
  1998.      LIST
  1999.      MOVE.L #1004,D2           ; Make D2 indicate "r/w" access mode.
  2000.      NOLIST
  2001.      ENDC
  2002.      ENDC
  2003.      IFEQ NARG-3               ; If new, read, or r/w is not specified,
  2004.      LIST
  2005.      MOVE.L #1005,D2           ; Make D2 indicate the old/new accessMode
  2006.      TST D0                    ;  based on D0.
  2007.      BNE 5$
  2008.      SUBQ #1,D2
  2009. 5$:
  2010.      NOLIST
  2011.      ENDC
  2012.      IFC '\1','I'              ; If <PointerToFileName> is specified, then
  2013.      LIST
  2014.                                ; Put <PointerToFileName> in D1.
  2015.      MOVE.L #\2,D1
  2016.      NOLIST
  2017.      IFEQ ReEntrant-1
  2018.      LIST
  2019.      ADD.L A5,D1
  2020.      NOLIST
  2021.      ENDC
  2022.      ENDC
  2023.      IFC '\1','D'              ; If <FileName> is specified, then
  2024.      LIST
  2025.                                ; Make D1 point to the file name string.
  2026.      MOVE.L #\2.str,D1
  2027.      NOLIST
  2028.      IFND \2.str               ; Unless it was previously defined,
  2029.      LIST
  2030.      SECTION DataSection,DATA  ; The ASCII <FileName> string goes here.
  2031. \2.str:
  2032.      DC.B '\2',0
  2033.      CNOP 0,2
  2034.      SECTION CodeSection,CODE
  2035.      NOLIST
  2036.      ENDC
  2037.      ENDC
  2038.      LIST
  2039.      CallLib Open,dos          ; Call Open to open <FileName>.
  2040.                                ; Put the file handle at <FileHandleName>.
  2041.      NOLIST
  2042.      IFEQ ReEntrant-1
  2043.      LIST
  2044.      DefDS \3,1
  2045.      MOVE.L D0,\3(A5)
  2046.      NOLIST
  2047.      ENDC
  2048.      IFNE ReEntrant-1
  2049.      LIST
  2050.      DS_BSS \3,1,.L
  2051.      MOVE.L D0,\3
  2052.      NOLIST
  2053.      ENDC
  2054.      LIST
  2055.      TST.L D0                  ; Make the zero flag indicate failure.
  2056. *------------------------------; End of Open macro.
  2057.      ENDM
  2058.  
  2059. *****************************************************************************
  2060.  
  2061. *****************************************************************************
  2062. *
  2063. *    ParentDir           dos.library  MACRO                 15 Sept 88
  2064. *
  2065. *    NAME:
  2066. *         ParentDir - Obtain the lock for the parent directory of the
  2067. *                      specified file or directory
  2068. *
  2069. *    SYNOPSIS:
  2070. *         ParentDir <ParentDirLockName> [,<FileLockName>]
  2071. *                                       [ or FileLock in D0 ]
  2072. *
  2073. *                  Returns:  Parent dir lock in D0 and at
  2074. *                             <ParentDirLockName>.
  2075. *                            Z-flag = 1 if the parent dir is the root of the
  2076. *                             current filing system.
  2077. *
  2078. *    FUNCTION:
  2079. *         This macro obtains the lock for the parent directory of the file
  2080. *          specified by <FileLockName> or alternately specified by the file
  2081. *          lock in D0. It returns a lock to the parent directory in D0 and at
  2082. *          the location "<ParentDirLockName>". If the parent dir is the root
  2083. *          of the current filing system, the parent directory lock will be
  2084. *          zero and the zero flag will be set.
  2085. *
  2086. *         See also CurrentDir, Lock.
  2087. *
  2088. *    INPUTS:
  2089. *         [<FileLockName>] - This is the name of the directory lock which was
  2090. *                             returned by the Lock macro. If this is not
  2091. *                             specified, D0 must contain the file lock.
  2092. *
  2093. *         <ParentDirLockName> - The name you want the parent directory lock
  2094. *                                to be called.
  2095. *
  2096. *         dos.library.LP   - Must have been defined by invoking the
  2097. *                             "OpenLib dos.library" macro command.
  2098. *
  2099. *    RESULTS:
  2100. *         parent dir lock  - Returned in D0 and in memory at the address
  2101. *                             labeled "<ParentDirLockName>".
  2102. *
  2103. *         parent was root  - Zero flag = true if the parent directory was the
  2104. *                             root.
  2105. *
  2106.  
  2107.  
  2108. ParentDir   MACRO
  2109. *------------------------------; Start of ParentDir macro.
  2110.      NOLIST
  2111.      IFEQ NARG-2               ; If <FileLockName> is given, then
  2112.      LIST
  2113.                                ; Get the file lock from <FileLockName>.
  2114.      NOLIST
  2115.      IFEQ ReEntrant-1
  2116.      LIST
  2117.      MOVE.L \2(A5),D1
  2118.      NOLIST
  2119.      ENDC
  2120.      IFNE ReEntrant-1
  2121.      LIST
  2122.      MOVE.L \2,D1
  2123.      NOLIST
  2124.      ENDC
  2125.      ENDC
  2126.      IFEQ NARG-1               ; If <FileLockName> is not given, then
  2127.      LIST
  2128.      MOVE.L D0,D1              ; Use the file lock given in D0.
  2129.      NOLIST
  2130.      ENDC
  2131.      LIST
  2132.      CallLib ParentDir,dos     ; Call ParentDir.
  2133.                                ; Save the parent directory lock at the named
  2134.                                ;  location.
  2135.      NOLIST
  2136.      IFEQ ReEntrant-1
  2137.      LIST
  2138.      DefDS \1,1
  2139.      MOVE.L D0,\1(A5)
  2140.      NOLIST
  2141.      ENDC
  2142.      IFNE ReEntrant-1
  2143.      LIST
  2144.      DS_BSS \1,1,.L
  2145.      MOVE.L D0,\1
  2146.      NOLIST
  2147.      ENDC
  2148.      LIST
  2149.      TST.L D0                  ; Make the zero flag indicate if parent dir
  2150.                                ;  was the root.
  2151. *------------------------------; End of ParentDir macro.
  2152.      ENDM
  2153.  
  2154. *****************************************************************************
  2155.  
  2156. *****************************************************************************
  2157. *
  2158. *    Read                dos.library  MACRO                      21 Dec 88
  2159. *
  2160. *    NAME:
  2161. *         Read  - Read a file into a buffer.
  2162. *
  2163. *    SYNOPSIS:
  2164. *         Read <FileHandleName>,D,<BufferStartAddr>
  2165. *         Read <FileHandleName>,D,<BufferStartAddr>,D3
  2166. *         Read <FileHandleName>,D,<BufferStartAddr>,<BufferSize>
  2167. *
  2168. *         Read <FileHandleName>,I,<MemBlockName>
  2169. *         Read <FileHandleName>,I,<MemBlockName>,D3
  2170. *         Read <FileHandleName>,I,<MemBlockName>,<BufferSize>
  2171. *
  2172. *                  Returns:  Data which was read in the buffer.
  2173. *                            Actual length of bytes read in D0 and at
  2174. *                             <BufferStartAddr>.Len or <MemBlockName>.Len.
  2175. *                            Z-flag = 1 if fail.
  2176. *
  2177. *    FUNCTION:
  2178. *         This macro reads bytes from an opened file into a buffer. The
  2179. *          buffer is either specified by <BufferStartAddr> or by a vector
  2180. *          located at <MemBlockName>.Adr .
  2181. *
  2182. *         If no fourth argument is given, and <BufferStartAddr> is
  2183. *          specified, the label "<BufferStartAddr>End" must exist one byte
  2184. *          past the end of the buffer.
  2185. *
  2186. *         If no fourth argument is given, and <MemBlockName> is specified,
  2187. *          the buffer size must be specified in <MemBlockName>.Size .
  2188. *
  2189. *         D3 may be used to specify the buffer size, or the buffer size may
  2190. *          be specified directly as <BufferSize>.
  2191. *
  2192. *         If "<BufferStartAddr>" is given as the third argument, then
  2193. *          "<BufferStartAddr>.Len" will be created, if it doesn't already
  2194. *          exist, so that the actual length may be stored there.
  2195. *
  2196. *         If "<MemBlockName>" is given as the third argument, then
  2197. *          "<MemBlockName>.Len" will be created, if it doesn't already
  2198. *          exist, so that the actual length may be stored there.
  2199. *
  2200. *         If it is not successful, it will set the zero flag.
  2201. *
  2202. *         See also Seek.
  2203. *
  2204. *    INPUTS:
  2205. *         "D" or "I"         - Indicates "direct" or "indirect" mode for
  2206. *                               the third argument.
  2207. *
  2208. *         <FileHandleName>   - Typed in as the first argument of the macro.
  2209. *                               Use the Open macro to create this.
  2210. *
  2211. *         <BufferStartAddr>  - Defined for the start of the buffer.
  2212. *
  2213. *         <MemBlockName>     - This is the same <MemBlockName> argument which
  2214. *                               was used for the AllocMem macro.
  2215. *
  2216. *         buffer size        - Specified in D3, or as <BufferSize>, or at
  2217. *                               <MemBlockName>.Size, or as <BufferStart
  2218. *                               Addr>End minus <BufferStartAddr>.
  2219. *
  2220. *         dos.library.LP     - Must have been defined by invoking the
  2221. *                               "OpenLib dos.library" macro command.
  2222. *
  2223. *    RESULTS:
  2224. *         read data     - Returned in the buffer labeled "<BufferName>".
  2225. *
  2226. *         actual length - Returns actual length of bytes read in D0 and at
  2227. *                          <BufferStartAddr>.Len or <MemBlockName>.Len.
  2228. *
  2229. *         fail          - Zero flag = true if failed, false if o.k.
  2230. *
  2231.  
  2232.  
  2233. Read        MACRO
  2234. *------------------------------; Start of Read macro.
  2235.                                ; Put the file handle in D1.
  2236.      NOLIST
  2237.      IFEQ ReEntrant-1
  2238.      LIST
  2239.      MOVE.L \1(A5),D1
  2240.      NOLIST
  2241.      ENDC
  2242.      IFNE ReEntrant-1
  2243.      LIST
  2244.      MOVE.L \1,D1
  2245.      NOLIST
  2246.      ENDC
  2247.      LIST
  2248.                                ; Make D2 point to the start of the buffer.
  2249.      NOLIST
  2250.      IFC '\2','D'
  2251.      LIST
  2252.      MOVE.L #\3,D2
  2253.      NOLIST
  2254.      IFEQ ReEntrant-1
  2255.      LIST
  2256.      ADD.L A5,D2
  2257.      NOLIST
  2258.      ENDC
  2259.      ENDC
  2260.      IFC '\2','I'
  2261.      IFEQ ReEntrant-1
  2262.      LIST
  2263.      MOVE.L \3.Adr(A5),D2
  2264.      NOLIST
  2265.      ENDC
  2266.      IFNE ReEntrant-1
  2267.      LIST
  2268.      MOVE.L \3.Adr,D2
  2269.      NOLIST
  2270.      ENDC
  2271.      ENDC
  2272.      IFEQ NARG-3               ; If there is no fourth argument, and
  2273.      IFC '\2','D'              ;  <BufferStartAddr> is specified, then
  2274.      LIST
  2275.                                ; Calculate the buffer size as
  2276.                                ;  <BufferStartAddr>End minus
  2277.                                ;  <BufferStartAddr>. Put it in D3.
  2278.      MOVE.L #\3End-\3,D3
  2279.      NOLIST
  2280.      ENDC
  2281.      IFC '\2','I'              ; If <MemBlockName> is specified, then
  2282.      LIST
  2283.                                ; Get the buffer size from <MemBlockName>.Size
  2284.      NOLIST
  2285.      IFEQ ReEntrant-1
  2286.      LIST
  2287.      MOVE.L \3.Size(A5),D3
  2288.      NOLIST
  2289.      ENDC
  2290.      IFNE ReEntrant-1
  2291.      LIST
  2292.      MOVE.L \3.Size,D3
  2293.      NOLIST
  2294.      ENDC
  2295.      ENDC
  2296.      ENDC
  2297.      IFEQ NARG-4               ; If the fourth argument exists,
  2298.      IFNC '\4','D3'            ;  and it is not "D3", then
  2299.      LIST
  2300.                                ; Use the buffer size of the fourth argument.
  2301.      MOVE.L #\4,D3
  2302.      NOLIST
  2303.      ENDC
  2304.      ENDC
  2305.      LIST
  2306.      CallLib Read,dos          ; Call Read.
  2307.                                ; Store the actual length read at \3.Len .
  2308.      NOLIST
  2309.      IFEQ ReEntrant-1
  2310.      LIST
  2311.      DefDS \3.Len,1
  2312.      MOVE.L D0,\3.Len(A5)
  2313.      NOLIST
  2314.      ENDC
  2315.      IFNE ReEntrant-1
  2316.      LIST
  2317.      DS_BSS \3.Len,1,.L
  2318.      MOVE.L D0,\3.Len
  2319.      NOLIST
  2320.      ENDC
  2321.      LIST
  2322.      CMPI.L #-1,D0             ; Make the zero flag indicate failure.
  2323. *------------------------------; End of Read macro.
  2324.      ENDM
  2325.  
  2326. *****************************************************************************
  2327.  
  2328. *****************************************************************************
  2329. *
  2330. *    Rename              dos.library  MACRO                 19 Dec 88
  2331. *
  2332. *    NAME:
  2333. *         Rename - Rename a directory or file
  2334. *
  2335. *    SYNOPSIS:
  2336. *         Rename D,<OldNameString>,D,<NewNameString>
  2337. *         Rename D,<OldNameString>,I,<PointerToNewNameString>
  2338. *         Rename D,<OldNameString>,R,D2
  2339. *
  2340. *         Rename I,<PointerToOldNameString>,D,<NewNameString>
  2341. *         Rename I,<PointerToOldNameString>,I,<PointerToNewNameString>
  2342. *         Rename I,<PointerToOldNameString>,R,D2
  2343. *
  2344. *         Rename R,D1,D,<NewNameString>
  2345. *         Rename R,D1,I,<PointerToNewNameString>
  2346. *         Rename R,D1,R,D2
  2347. *
  2348. *                  Returns:  Z-flag = 1 if fail.
  2349. *
  2350. *    FUNCTION:
  2351. *         This macro renames a file or directory specified by the "old name
  2352. *          string" with the name specified by "new name string". The "name
  2353. *          strings" must be null-terminated. If it is not successful, it will
  2354. *          set the zero flag.
  2355. *
  2356. *    INPUTS:
  2357. *         "D","I" or "R"       - Indicates "direct", "indirect", or
  2358. *                                 "register" mode for the second and fourth
  2359. *                                  arguments.
  2360. *
  2361. *     <PointerToOldNameString> - The pointer to the name the file should be
  2362. *                                 changrd from.
  2363. *
  2364. *     <PointerToNewNameString> - The pointer to the name the file should be
  2365. *                                 changrd to.
  2366. *
  2367. *         dos.library.LP       - Must have been defined by invoking the
  2368. *                                 "OpenLib dos.library" macro command.
  2369. *
  2370. *    RESULTS:
  2371. *         fail        - Zero flag = true if failed, false if o.k.
  2372. *
  2373.  
  2374.  
  2375. Rename      MACRO
  2376. *------------------------------; Start of Rename macro.
  2377.      NOLIST
  2378.      IFC '\1','I'              ; If <PointerToOldNameString> is specified,
  2379.      LIST
  2380.                                ; Put <PointerToOldNameString> in D1.
  2381.      MOVE.L #\2,D1
  2382.      NOLIST
  2383.      IFEQ ReEntrant-1
  2384.      LIST
  2385.      ADD.L A5,D1
  2386.      NOLIST
  2387.      ENDC
  2388.      ENDC
  2389.      IFC '\1','D'              ; If <OldNameString> is specified, then
  2390.      LIST
  2391.                                ; Make D1 point to <OldNameString>.
  2392.      MOVE.L #\2.str,D1
  2393.      NOLIST
  2394.      IFND \2.str               ; Unless it was previously defined,
  2395.      LIST
  2396.      SECTION DataSection,DATA  ; The ASCII <OldNameString> string goes here.
  2397. \2.str:
  2398.      DC.B '\2',0
  2399.      CNOP 0,2
  2400.      SECTION CodeSection,CODE
  2401.      NOLIST
  2402.      ENDC
  2403.      ENDC
  2404.      IFC '\3','I'              ; If <PointerToNewNameString> is specified,
  2405.      LIST
  2406.                                ; Put <PointerToNewNameString> in D1.
  2407.      MOVE.L #\4,D1
  2408.      NOLIST
  2409.      IFEQ ReEntrant-1
  2410.      LIST
  2411.      ADD.L A5,D1
  2412.      NOLIST
  2413.      ENDC
  2414.      ENDC
  2415.      IFC '\3','D'              ; If <NewNameString> is specified, then
  2416.      LIST
  2417.                                ; Make D1 point to <NewNameString>.
  2418.      MOVE.L #\4.str,D1
  2419.      NOLIST
  2420.      IFND \4.str               ; Unless it was previously defined,
  2421.      LIST
  2422.      SECTION DataSection,DATA  ; The ASCII <NewNameString> string goes here.
  2423. \4.str:
  2424.      DC.B '\4',0
  2425.      CNOP 0,2
  2426.      SECTION CodeSection,CODE
  2427.      NOLIST
  2428.      ENDC
  2429.      ENDC
  2430.      LIST
  2431.      CallLib Rename,dos        ; Call Rename.
  2432.      TST.L D0                  ; Make the zero flag indicate failure.
  2433. *------------------------------; End of Rename macro.
  2434.      ENDM
  2435.  
  2436. *****************************************************************************
  2437.  
  2438. *****************************************************************************
  2439. *
  2440. *    Seek                dos.library  MACRO                 15 Sept 88
  2441. *
  2442. *    NAME:
  2443. *         Seek - Move the read/write cursor position in a file and get the
  2444. *                 old position
  2445. *
  2446. *    SYNOPSIS:
  2447. *         Seek <FileHandleName> [,<offset> [, FromCurrent | BeforeEnd ] ]
  2448. *
  2449. *                  Returns:  Old cursor position D0.
  2450. *                            Z-flag = 1 if fail.
  2451. *
  2452. *    FUNCTION:
  2453. *         This macro moves the read/write cursor position in a file, and
  2454. *          returns the old cursor position. If only the <FileHandleName> is
  2455. *          specified, the macro reads the position without moving the
  2456. *          position. If niether FromCurrent or BeforeEnd is specified, the
  2457. *          position is relative to the beginning of the file. If it is not
  2458. *          successful, it will set the zero flag.
  2459. *
  2460. *         See also Read, Write.
  2461. *
  2462. *    INPUTS:
  2463. *         <FileHandleName> - Typed in as the first argument of the macro.
  2464. *                             Use the Open macro to create this.
  2465. *
  2466. *         [<offset>]       - Value of the offset from start, from current or
  2467. *                             before the end.
  2468. *
  2469. *         [ FromCurrent ]  - Specifies that offset is from current position
  2470. *         [ or BeforeEnd ]    or before the end. If offset is specified
  2471. *                             without specifing FromCurrent or BeforeEnd,
  2472. *                             offset will be from the beginning. This macro
  2473. *                             argument may not be given if offset is not also
  2474. *                             given.
  2475. *
  2476. *         dos.library.LP   - Must have been defined by invoking the
  2477. *                             "OpenLib dos.library" macro command.
  2478. *
  2479. *    RESULTS:
  2480. *         old position  - Returned in D0.
  2481. *
  2482. *         fail          - Zero flag = true if failed, false if o.k.
  2483. *
  2484.  
  2485.  
  2486. Seek        MACRO
  2487. *------------------------------; Start of Seek macro.
  2488.                                ; Put the file handle in D1.
  2489.      NOLIST
  2490.      IFEQ ReEntrant-1
  2491.      LIST
  2492.      MOVE.L \1(A5),D1
  2493.      NOLIST
  2494.      ENDC
  2495.      IFNE ReEntrant-1
  2496.      LIST
  2497.      MOVE.L \1,D1
  2498.      NOLIST
  2499.      ENDC
  2500.      IFEQ NARG-1               ; If only the file handle was given, then
  2501.      LIST
  2502.      CLR.L D2                  ; Make offset be zero from current.
  2503.      CLR.L D3
  2504.      NOLIST
  2505.      ENDC
  2506.      IFEQ NARG-2               ; If offset was given without argument #3,
  2507.      LIST
  2508.                                ; Make offset be from the beginning.
  2509.      MOVE.L #\2,D2
  2510.      MOVEQ.L #-1,D3
  2511.      NOLIST
  2512.      ENDC
  2513.      IFEQ NARG-3               ; If FromCurrent or BeforeEnd is specified,
  2514.      IFC '\3','FromCurrent'
  2515.      LIST
  2516.      CLR.L D3                  ; Make offset from current.
  2517.      MOVE.L #\2,D2
  2518.      NOLIST
  2519.      ENDC
  2520.      IFC '\3','BeforeEnd'
  2521.      LIST
  2522.      MOVEQ #1,D3               ; Make offset before end.
  2523.      MOVE.L #-\2,D2
  2524.      NOLIST
  2525.      ENDC
  2526.      ENDC
  2527.      LIST
  2528.      CallLib Seek,dos          ; Call Seek.
  2529.      CMPI.L #-1,D0             ; Make the zero flag indicate failure.
  2530. *------------------------------; End of Seek macro.
  2531.      ENDM
  2532.  
  2533. *****************************************************************************
  2534.  
  2535. *****************************************************************************
  2536. *
  2537. *    SetComment          dos.library  MACRO                 15 Sept 88
  2538. *
  2539. *    NAME:
  2540. *         SetComment - Set a comment on a file or directory
  2541. *
  2542. *    SYNOPSIS:
  2543. *         SetComment <PointerToFileNameString>,<PointerToCommentString>
  2544. *
  2545. *                  Returns:  Z-flag = 1 if fail.
  2546. *
  2547. *    FUNCTION:
  2548. *         This macro sets a comment on a file or directory specified by the
  2549. *          "file name string". The "comment string" must be no more than 80
  2550. *          characters long. Both strings must be null-terminated. If it is
  2551. *          not successful, it will set the zero flag.
  2552. *
  2553. *    INPUTS:
  2554. *     <PointerToFileNameString> - The pointer to the name of the file.
  2555. *
  2556. *     <PointerToCommentString>  - The pointer to the comment string.
  2557. *
  2558. *         dos.library.LP       - Must have been defined by invoking the
  2559. *                                 "OpenLib dos.library" macro command.
  2560. *
  2561. *    RESULTS:
  2562. *         fail        - Zero flag = true if failed, false if o.k.
  2563. *
  2564.  
  2565.  
  2566. SetComment  MACRO
  2567. *------------------------------; Start of SetComment macro.
  2568.                                ; Do set-up for _LVOSetComment.
  2569.      MOVE.L #\1,D1
  2570.      MOVE.L #\2,D2
  2571.      NOLIST
  2572.      IFEQ ReEntrant-1
  2573.      LIST
  2574.      ADD.L A5,D1
  2575.      ADD.L A5,D2
  2576.      NOLIST
  2577.      ENDC
  2578.      LIST
  2579.      CallLib SetComment,dos    ; Call SetComment.
  2580.      TST.L D0                  ; Make the zero flag indicate failure.
  2581. *------------------------------; End of SetComment macro.
  2582.      ENDM
  2583.  
  2584. *****************************************************************************
  2585.  
  2586. *****************************************************************************
  2587. *
  2588. *    UnLock              dos.library  MACRO                 15 Sept 88
  2589. *
  2590. *    NAME:
  2591. *         UnLock  - Unlock a directory or file.
  2592. *
  2593. *    SYNOPSIS:
  2594. *         UnLock <LockName>
  2595. *
  2596. *                  Returns:  Nothing.
  2597. *
  2598. *    FUNCTION:
  2599. *         This macro unlocks a directory or file.
  2600. *
  2601. *         See also Lock.
  2602. *
  2603. *    INPUTS:
  2604. *         <LockName>     - The name of the lock to be removed.
  2605. *
  2606. *         dos.library.LP - Must have been defined by invoking the
  2607. *                             "OpenLib dos.library" macro command.
  2608. *
  2609.  
  2610.  
  2611. UnLock      MACRO
  2612. *------------------------------; Start of UnLock macro.
  2613.                                ; Put the lock in D1.
  2614.      NOLIST
  2615.      IFEQ ReEntrant-1
  2616.      LIST
  2617.      MOVE.L \1(A5),D1
  2618.      NOLIST
  2619.      ENDC
  2620.      IFNE ReEntrant-1
  2621.      LIST
  2622.      MOVE.L \1,D1
  2623.      NOLIST
  2624.      ENDC
  2625.      LIST
  2626.      CallLib UnLock,dos        ; Call UnLock to remove the lock.
  2627.  
  2628. *------------------------------; End of UnLock macro.
  2629.      ENDM
  2630.  
  2631. *****************************************************************************
  2632.  
  2633. *****************************************************************************
  2634. *
  2635. *    WaitForChar         dos.library  MACRO                 15 Sept 88
  2636. *
  2637. *    NAME:
  2638. *         WaitForChar - Wait for a character to arrive at a virtual terminal
  2639. *                        within a time limit
  2640. *
  2641. *    SYNOPSIS:
  2642. *         WaitForChar <FileHandleName>,<timeout>
  2643. *
  2644. *                  Returns:  Z-flag = 0 if char is available
  2645. *                            Z-flag = 1 if char is not available
  2646. *
  2647. *    FUNCTION:
  2648. *         This macro waits for a character to arrive at a virtual terminal
  2649. *          (i.e. window), or for a specified amount of time to elapse,
  2650. *          whichever occurs first. The value of <timeout> is specified in
  2651. *          hundredths of seconds.
  2652. *
  2653. *    INPUTS:
  2654. *         <FileHandleName> - Typed in as the first argument of the macro.
  2655. *                             Use the Open macro to create this.
  2656. *
  2657. *         <timeout>        - The maximum time to wait in hundredths of
  2658. *                             seconds.
  2659. *
  2660. *         dos.library.LP   - Must have been defined by invoking the
  2661. *                             "OpenLib dos.library" macro command.
  2662. *
  2663. *    RESULTS:
  2664. *         Char available     - Zero flag = true if char is not available.
  2665. *         or not available               = false if char is available.
  2666. *
  2667.  
  2668.  
  2669. WaitForChar  MACRO
  2670. *------------------------------; Start of WaitForChar macro.
  2671.                                ; Put file handle in D1.
  2672.      NOLIST
  2673.      IFEQ ReEntrant-1
  2674.      LIST
  2675.      MOVE.L \1(A5),D1
  2676.      NOLIST
  2677.      ENDC
  2678.      IFNE ReEntrant-1
  2679.      LIST
  2680.      MOVE.L \1,D1
  2681.      NOLIST
  2682.      ENDC
  2683.      LIST
  2684.                                ; Put timeout in D2.
  2685.      MOVE.L #\2*10000,D2
  2686.      CallLib WaitForChar,dos   ; Call WaitForChar.
  2687.      TST.L D0                  ; Make the Z-flag indicate char availability.
  2688. *------------------------------; End of WaitForChar macro.
  2689.      ENDM
  2690.  
  2691. *****************************************************************************
  2692.  
  2693. *****************************************************************************
  2694. *
  2695. *    Write               dos.library  MACRO                      21 Dec 88
  2696. *
  2697. *    NAME:
  2698. *         Write - Write to a file from a buffer.
  2699. *
  2700. *    SYNOPSIS:
  2701. *         Write D,<BufferStartAddr>,<FileHandleName>
  2702. *         Write D,<BufferStartAddr>,<FileHandleName>,D3
  2703. *         Write D,<BufferStartAddr>,<FileHandleName>,<BufferSize>
  2704. *
  2705. *         Write R,D2,<FileHandleName>,D3
  2706. *         Write R,D2,<FileHandleName>,<BufferSize>
  2707. *
  2708. *         Write I,<MemBlockName>,<FileHandleName>
  2709. *         Write I,<MemBlockName>,<FileHandleName>,D3
  2710. *         Write I,<MemBlockName>,<FileHandleName>,<BufferSize>
  2711. *
  2712. *                  Returns:  Actual length of bytes written in D0.
  2713. *                            Z-flag = 1 if fail.
  2714. *
  2715. *    FUNCTION:
  2716. *         This macro writes bytes from a buffer to an opened file. The buffer
  2717. *          is either specified by a vector located at <MemBlockName>.Adr or
  2718. *          by <BufferStartAddr>.
  2719. *
  2720. *         If no fourth argument is given, and <BufferStartAddr> is
  2721. *          specified, the label "<BufferStartAddr>End" must exist one byte
  2722. *          past the end of the buffer.
  2723. *
  2724. *         If no fourth argument is given, and <MemBlockName> is specified,
  2725. *          the buffer size must be specified in <MemBlockName>.Size .
  2726. *
  2727. *         D3 may be used to specify the buffer size, or the buffer size may
  2728. *          be specified directly as <BufferSize>.
  2729. *
  2730. *         If it is not successful, it will set the zero flag.
  2731. *
  2732. *    INPUTS:
  2733. *         "D","I" or "R"      - Indicates "direct", "indirect", or "register"
  2734. *                                mode for the second argument.
  2735. *
  2736. *         <FileHandleName>   - Typed in as the third argument of the macro.
  2737. *                               Use the Open macro to create this.
  2738. *
  2739. *         <BufferStartAddr>  - Defined for the start of the buffer.
  2740. *
  2741. *         <MemBlockName>     - This is the same <MemBlockName> argument which
  2742. *                               was used for the AllocMem macro.
  2743. *
  2744. *         buffer size        - Specified in D3, or as <BufferSize>, or at
  2745. *                               <MemBlockName>.Size, or as
  2746. *                               <BufferStartAddr>End minus <BufferStartAddr>.
  2747. *
  2748. *         dos.library.LP     - Must have been defined by invoking the
  2749. *                               "OpenLib dos.library" macro command.
  2750. *
  2751. *    RESULTS:
  2752. *         actual length - Returns actual length of bytes written in D0.
  2753. *
  2754. *         fail          - Zero flag = true if failed, false if o.k.
  2755. *
  2756.  
  2757.  
  2758. Write       MACRO
  2759. *------------------------------; Start of Write macro.
  2760.                                ; Put the file handle in D1.
  2761.      NOLIST
  2762.      IFEQ ReEntrant-1
  2763.      LIST
  2764.      MOVE.L \3(A5),D1
  2765.      NOLIST
  2766.      ENDC
  2767.      IFNE ReEntrant-1
  2768.      LIST
  2769.      MOVE.L \3,D1
  2770.      NOLIST
  2771.      ENDC
  2772.      LIST
  2773.                                ; Make D2 point to the start of the buffer.
  2774.      NOLIST
  2775.      IFC '\1','D'
  2776.      LIST
  2777.      MOVE.L #\2,D2
  2778.      NOLIST
  2779.      ENDC
  2780.      IFC '\1','I'
  2781.      IFEQ ReEntrant-1
  2782.      LIST
  2783.      MOVE.L \2.Adr(A5),D2
  2784.      NOLIST
  2785.      ENDC
  2786.      IFNE ReEntrant-1
  2787.      LIST
  2788.      MOVE.L \2.Adr,D2
  2789.      NOLIST
  2790.      ENDC
  2791.      ENDC
  2792.      IFEQ NARG-3               ; If there is no fourth argument, and
  2793.      IFC '\1','D'              ;  <BufferStartAddr> is specified, then
  2794.      LIST
  2795.                                ; Calculate the buffer size as
  2796.                                ;  <BufferStartAddr>End minus
  2797.                                ;  <BufferStartAddr>. Put it in D3.
  2798.      MOVE.L #\2End-\2,D3
  2799.      NOLIST
  2800.      ENDC
  2801.      IFC '\1','I'              ; If <MemBlockName> is specified, then
  2802.      LIST
  2803.                                ; Get the buffer size from <MemBlockName>.Size
  2804.      NOLIST
  2805.      IFEQ ReEntrant-1
  2806.      LIST
  2807.      MOVE.L \2.Size(A5),D3
  2808.      NOLIST
  2809.      ENDC
  2810.      IFNE ReEntrant-1
  2811.      LIST
  2812.      MOVE.L \2.Size,D3
  2813.      NOLIST
  2814.      ENDC
  2815.      ENDC
  2816.      ENDC
  2817.      IFEQ NARG-4               ; If the fourth argument exists,
  2818.      IFNC '\4','D3'            ;  and it is not "D3", then
  2819.      LIST
  2820.                                ; Use the buffer size of the fourth argument.
  2821.      MOVE.L #\4,D3
  2822.      NOLIST
  2823.      ENDC
  2824.      ENDC
  2825.      LIST
  2826.      CallLib Write,dos         ; Call Write.
  2827.      CMPI.L #-1,D0             ; Make the zero flag indicate failure.
  2828. *------------------------------; End of Write macro.
  2829.      ENDM
  2830.  
  2831. *****************************************************************************
  2832.  
  2833.